Database Reference
In-Depth Information
How It Works
The .edmx file contains all three model layers: conceptual, mapping, and storage. The file also contains additional
data used by the designer to manage the design surface. At runtime, Entity Framework uses each of the layers
separately. The .edmx file is just a convenient container for the design time user experience. The deployment of a
model depends on model layers either embedded in the assembly, stored in files, or, as we saw in Recipe 7-2, retrieved
from another source and used to complete a MetadataWorkspace.
If your Metadata Artifact Processing property is set to Embed in Output Assembly, you will notice that the
connection string in your App.config or web.config file includes a metadata tag, which looks something like the
following:
metadata=res://*/Recipe3.csdl|res://*/Recipe3.ssdl|res://*/Recipe3.msl;
This notation indicates a search path for each of the model layers embedded in the assembly. If you change
the Metadata Artifact Processing property to Copy to Output Directory, you will see the connection string change to
something like this:
metadata=.\Recipe3.csdl|.\Recipe3.ssdl|.\Recipe3.msl;
This notation indicates a file path to each of the model layers.
When embedding the model layers as resources in an assembly, you are not restricted by the connection string
syntax to referencing only the executing assembly. Table 7-1 illustrates some of the possible constructions you can use
to reference the embedded model layers in other assemblies.
Table 7-1. Connection String Syntax for Loading Model Layers
Syntax
Meaning
res://myassembly/file.ssdl
Loads the SSDL from myassembly
res://myassembly/
Loads the SSDL, CSDL, and MSL from myassembly
res://*/file.ssdl
Loads the SSDL from all assemblies in the AppDomain
res://*/
Loads the SSDL, CSDL, and MSL from all assemblies
7-4. Using the Pluralization Service
Problem
You want to use Entity Framework's Pluralization Service when you import a table from a database.
Solution
Suppose that you have a database with the tables shown in Figure 7-3 .
 
Search WWH ::




Custom Search