Export (0) Print
Expand All

How to: Make Model and Mapping Files Embedded Resources (Entity Framework)

The Entity Framework enables you to deploy Entity Data Model (EDM) model and mapping files as embedded resources of an application. The assembly with the embedded model and mapping files must be loaded in the same application domain as the entity connection. For more information, see Connection Strings (Entity Framework). By default, the Entity Data Model tools embed EDM model and mapping files. When you use EdmGen or manually define an EDM, use this procedure to ensure that model and mapping files are deployed as embedded resources with an Entity Framework application.


To maintain embedded resources, you must repeat this procedure whenever the EDM is modified.

To embed model and mapping files.

  1. In Solution Explorer, select the .csdl conceptual model file.

  2. In the Properties pane, set Build Action to Embedded Resource.

  3. Repeat steps 1 and 2 for the .ssdl storage model file and the .msl mapping file.

  4. In Solution Explorer, double-click the App.config file and then modify the Metadata parameter in the connectionString attribute based on one of the following formats:

    • Metadata= res://<assemblyFullName>/<resourceName>;

    • Metadata= res://*/<resourceName>;

    • Metadata=res://*;

    For more information, see Connection Strings (Entity Framework).


The following connection string references embedded EDM model and mapping files for the AdventureWorks Sales Model. This connection string is stored in the project's App.config file.

      <add name="AdventureWorksEntities" connectionString="metadata=
              provider=System.Data.SqlClient;provider connection string='Data Source=localhost;
           Initial Catalog=AdventureWorks;Integrated Security=True;'"
           providerName="System.Data.EntityClient" />

See Also

Community Additions

© 2014 Microsoft