The Entity Designer of Visual Studio 2008 stores its data in an XML file with the extension .edmx. In the first part of this series I covered the Storage Model, the second part dealt with the Conceptual Model.
This part covers the Mappings section with regard to C# mappings. The Mapping section uses the xmlns:cs namespace
- xmlns:cs=”urn:schemas-microsoft-com:windows:storage:mapping:CS”
For tables and views, the mapping section defines the mappings from database object to C# class (EntitySets and EntityTypes), along with their scalar properties:
<edmx:Mappings> <cs:Mapping Space="C-S" > <cs:EntityContainerMapping StorageEntityContainer="MyNamespaceEntitiesStoreContainer" CdmEntityContainer="MyEntities"> <cs:EntitySetMapping Name="TableFooSet"> <cs:EntityTypeMapping TypeName="IsTypeOf(My.Namespace.Entities.TableFoo)"> <cs:MappingFragment StoreEntitySet="TABLEFOO"> <cs:ScalarProperty Name="ID" ColumnName="ID" /> <cs:ScalarProperty Name="Name" ColumnName="NAME" /> </cs:MappingFragment> </cs:EntityTypeMapping> </cs:EntitySetMapping> <cs:AssociationSetMapping Name="FK_TABLEFOO_TABLEBAR" TypeName="My.Namespace.Entities.FK_TABLEFOO_TABLEBAR" StoreEntitySet="TABLEFOO"> <cs:EndProperty Name="TABLEFOO"> <cs:ScalarProperty Name="ID" ColumnName="ID" /> </cs:EndProperty> <cs:EndProperty Name="TableBar"> <cs:ScalarProperty Name="ID" ColumnName="BAR_ID" /> </cs:EndProperty> <cs:Condition ColumnName="BAR_ID" IsNull="false" /> </cs:AssociationSetMapping> <cs:FunctionImportMapping FunctionImportName="SPBarFromFoo" FunctionName="My.Namespace.Entities.Store.SP_BAR_FROM_FOO" />
End of Mapping section, end of Runtime declarations
</cs:EntityContainerMapping> </cs:Mapping> </edmx:Mappings> </edmx:Runtime>
The rest of the edmx file contains the edmx:Designer section with layout information (shapes, connectors).