A "Data First" Entity Data Model (EDM) is related to a database by an Entity Framework connection string. This topic shows you how to find and review the Entity Framework connection string.
The EDM Designer shows the Entity Framework connection string in the "Properties" window:
Hover the mouse over the "Connection string" value and it appears as a tool-tip.
Note the "Metadata Artifact Processing" value indicates that the CSDL, SSDL, and MSL files are embedded as resources in the project assembly.
The connection string is not stored in the EDMX. It is held in a .NET configuration file. The Entity Framework designer writes the connection string to the Web.config if model is created in the web application project; it creates and writes the string to an App.config if the model is created in its own project.
The XML for the connection string is the same in either file and might look something like this:
XML | <connectionStrings> <add name="NorthwindIBEntities" connectionString=" metadata=res://*/DomainModel.csdl|res://*/DomainModel.ssdl|res://*/DomainModel.msl; provider=System.Data.SqlClient; provider connection string= " data source=localhost; initial catalog=NorthwindIB; integrated security=True; multipleactiveresultsets=True; App=EntityFramework "" providerName="System.Data.EntityClient" /> </connectionStrings> |
The config XML <connectionString> has three parts:
The name of this connection string, "NorthwindIBEntities", matches the DevForce data source key name for the model. DevForce writes this data source key name into every entity class generated from the model. That's how the DevForce runtime knows which database holds entities of this type.
The inner Entity Framework connection string has parts of its own:
The "metadata" fragment tells us the names of the metadata artifact files. The "res://*/" segment means these files are embedded as resources in the model assembly; there would be a file path name if the artifact files were loose in the output folder.
The root name, "DomainModel" in this example, must match the EDMX file name.
If you rename the EDMX file, be sure to update the names of the metadata artifact files in this string. The Entity Framework won't be able to find the artifact files if the connection string has the old names.