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 Conceptual Model describes the EntitySets, Entities, AssociationSets and Associations as .Net classes and attributes in the xmlns:edm and xmlns:a schemas
- xmlns:edm=”http://schemas.microsoft.com/ado/2006/04/edm”
- xmlns:a=”http://schemas.microsoft.com/ado/2006/04/codegeneration”
<edmx:ConceptualModels> <edm:Schema Namespace="My.Namespace.Entities" Alias="Self" xmlns="http://schemas.microsoft.com/ado/2006/04/edm"> <edm:EntityContainer Name="MyEntities"> <edm:EntitySet Name="TableFooSet" EntityType="My.Namespace.Entities.TableFoo" /> <edm:AssociationSet Name="FK_TABLEFOO_TABLEBAR" Association="My.Entities.FK_TABLEFOO_TABLEBAR"> <edm:End Role="TableBar" EntitySet="TableBarSet" /> <edm:End Role="TableFoo" EntitySet="TableFooSet" /> </edm:AssociationSet> <edm:FunctionImport Name="SPBarFromFoo"> <edm:Parameter Name="FooID" Mode="In" Type="Int32" /> <edm:Parameter Name="BarID" Mode="InOut" Type="Int32" /> </edm:FunctionImport> </edm:EntityContainer>
The Entity Container lists all sets. Then the entity description is listed in terms of Properties (columns) and Navigational Properties (foreign keys). NavigationalProperties are present in both tables of a foreign key relation:
<edm:EntityType Name="TableFoo"> <edm:Key> <edm:PropertyRef Name="ID" /> </edm:Key> <edm:Property Name="ID" Type="Int32" Nullable="false" /> <edm:Property Name="Serial" Type="String" Nullable="false" MaxLength="20" Unicode="true" FixedLength="false" /> <edm:NavigationProperty Name="Bar" Relationship="My.Namespace.Entities.FK_TABLEFOO_TABLEBAR" FromRole="TableFoo" ToRole="TableBar" /> </edm:EntityType> <edm:Association Name="FK_TABLEFOO_TABLEBAR"> <edm:End Type="My.Namespace.Entities.TableBar" Role="TABLEBAR" Multiplicity="1" /> <edm:End Type="My.Namespace.Entities.TableFoo" Role="TABLEFOO" Multiplicity="*" /> </edm:Association>
The xmlns:a schema is used if property getter or setter have been assigned non-public visibility:
<edm:NavigationProperty Name="TABLEBAR" Relationship="My.Namespace.Entities.FK_TABLEBAR_TABLEBLAH" FromRole="TABLEBLAH" ToRole="TABLEBAR" a:GetterAccess="Private" a:SetterAccess="Private" />
The end of the Conceptual Model
</edm:Schema> </edmx:ConceptualModels>
Pingback: Structure and Analysis of edmx Files (3) « devioblog
Pingback: Generating Wiki Documentation from Entity Framework edmx File « devioblog