Changing the name of the Entity Framework Connection String

ado.net ado.net-entity-data-model entity-framework

Question

How may the connection string name that Entity Framework models are by default tied to be changed?

Let's assume I use the Visual Studio add new item dialog to construct an Entity Framework data model called "Model1.edmx" by referring it to a database called "MyDb" and selecting some items to map. The wizard automatically inserted a connection string called "MyDbEntities" to the project's App.Config file since the EF model is in a class library project. By default, my model uses this connection string.

I am aware that I may provide a connection string to a constructor for the object context of my model, but how can I modify the connection string's default name?

VS 2010 Beta 2 is what I'm using.

1
10
2/17/2010 12:58:17 PM

Accepted Answer

The Entity Container Name of your model is exactly what is used as the default connection string name.

On order to alter the Entity Container Name, open your model, click in a blank space, and then navigate to the Properties window.

Keep in mind that there are additional uses for the Entity Container Name. For instance, it's your class name.ObjectContext subtype is used in the creation ofEntityKey s.

14
2/17/2010 2:20:42 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow