views:

458

answers:

1

I created an Entity Framework file. My database is called MyDB. My Entity Framework file is MyDB.edmx and I used an existing connection string (MyDBConnectionString) to generate the edmx model.

It created two more connection strings:
MyDBEntities
MyDBContainer

What are these for? They look exactly the same and both have the information from my old connection string.

Do I still need my old connection string?

Update with more information:

Here are the connection strings:

<add name="MyDBConnectionString" connectionString="Data Source=localhost;Initial Catalog=MyDB;Persist Security Info=False;User ID=MyDB;Password=MyDB" providerName="System.Data.SqlClient" />
<add name="MyDBEntities" connectionString="metadata=res://*/App_Code.MyDB.csdl|res://*/App_Code.MyDB.ssdl|res://*/App_Code.MyDB.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=localhost;Initial Catalog=MyDB;Persist Security Info=True;User ID=MyDB;Password=MyDB;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient" />
<add name="MyDBContainer" connectionString="metadata=res://*/App_Code.MyDB.csdl|res://*/App_Code.MyDB.ssdl|res://*/App_Code.MyDB.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=localhost;Initial Catalog=MyDB;Persist Security Info=True;User ID=MyDB;Password=MyDB;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient" />

I created the first one called MyDBConnectionString. Then, when I generated the edmx model from the database visual studio created the MyDBEntities and MyDBContainer connection strings. What are the other two (Entities and Container) for? Do I not need the original connection string anymore?

+1  A: 

You have three connectionStrings. Two are EF connectionStrings, one (MyDBConnectionString) is for ADO.NET.

You only need one of the EF connectionStrings. Keep the one which your model refers to. It will have the same name as the model itself.

You should probably keep MyDBConnectionString, too. If you want to use forms authentication, for example, you'll need that connectionString if you configure a SQL membership provider. They should both be kept in sync to point to the same DB.

Craig Stuntz
Thanks very much for the explaination.
metanaito