AliPanahi2
AliPanahi2

Reputation: 33

Which Connection String is correct?

i write a program with mvc and entity framework. i have problem with connection string.

my host say your connection string must be like follow:

Server=sql2005.yourdomain.com,1430;Database=databaseName;Uid=userName;Password=password;

and connection string in my program is:

<add name="sbiEntities" connectionString="metadata=res://*/Models.modelCompany.csdl|res://*/Models.modelCompany.ssdl|res://*/Models.modelCompany.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=(LocalDB)\v11.0;attachdbfilename=|DataDirectory|\sbi.mdf;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />

how change it?

Upvotes: 1

Views: 240

Answers (2)

Rune G
Rune G

Reputation: 1537

An EF connection string is divided into several parts divided by a semicolon (;).

  • The first part is the model metadata, this is autogenerated from your edmx file.

  • The second part is the provider EF should use to communicate with your storage.

  • The third part is the provider connection string which is your current connection string (line wrapped for readability):

    ...provider connection string=&quot;data source=(LocalDB)\v11.0; attachdbfilename=|DataDirectory|\sbi.mdf; integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;

    The text between the two &quot; is your current connection string and is the one that should be replaced. Be aware to keep the MultipleActiveResultSets=True, and switch the App=EntityFramework with an application name that reflects your application for easier diagnostic.

Upvotes: 1

Arnab
Arnab

Reputation: 544

Entity Framework having a special type of connection string which have CSDL, SSDL, MSL and your original connection string.

Conceptual schema definition language (CSDL): This section describe your conceptual model of EDMX file.

Storage schema definition language (SSDL): This section describe the database schema model of EDMX file.

Mapping specification language (MSL): This section is for the mappings of the two world (CSDL and SSDL).

EF actually get the CSDL, SSDL and MSL file names from the connection string.

Upvotes: 1

Related Questions