A preliminary study on the links in EntityFramework

Source: Internet
Author: User

Many people use EF's default link factory: System.Data.Entity.Infrastructure.LocalDbConnectionFactory

Then I didn't get used to it, and then I studied it, as follows

Then there is

Public System.Data.Common.DbConnection createconnection (string nameorconnectionstring)
Members of the System.Data.Entity.Infrastructure.LocalDbConnectionFactory

Summary:
Creates a connection for SQL Server LocalDb based on the given database name or connection string. If the given string contains a "=" character, it is treated as a full connection string, otherwise it is treated as a database name only.

Parameters:
Nameorconnectionstring: Database name or connection string.

return value:
The initialized DbConnection.

This is also why you can use the "name= database link name" meaning.

Many people are basically using the model Frist and DB Frist when they name the entity DbContext name

Followed by

Member of Sqlconnectionfactory BaseConnectionString

public string BaseConnectionString {get;}
Members of the System.Data.Entity.Infrastructure.SqlConnectionFactory

Summary:
The connection string to use for the option of a database other than "initial directory". When you call CreateConnection, the initial directory is preset based on the database name before this string. The default value is "Data source=.\sqlexpress; Integrated security=true; Multipleactiveresultsets=true ".

return value:
The connection string.

Member of the Localdbconnectionfactory baseconnectionstring

public string BaseConnectionString {get;}
Members of the System.Data.Entity.Infrastructure.LocalDbConnectionFactory

Summary:
Connection string for database options other than initial directory, data source, and AttachDbFileName. When CreateConnection is called, "Initial directory" and "AttachDbFileName" are added based on the database name before this string. The data source is set based on the localdbversion parameter. The default value is "Integrated security=true; Multipleactiveresultsets=true; ".

The default values for both are not the same.

I used the EF4.4 version, found that the link factory has three,sqlconnectionfactory,localdbconnectionfactory,sqlceconnectionFactory. The last one is for small database sqlce,access and so on.

A preliminary study on the links in EntityFramework

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.