IT:AD:EF:Concepts:EDMX File

  • EDM stands for Entity Data Model …using Xml
    • based on Entity Relationship Modeling (concept since 1975)
  • *.EDMX file is one file in design time, split in run time to 3 files:
    • *.CSDL part, the Conceptual Schema Definition Model - the Conceptional Model
    • *.MSL part, the Mapping Schema Language part - the Map
    • *.SSDL part, the Storage Schema Definition Language part - the Storage/Logical part
  • *.emdx causes automatic code generation:
    • Model1.edmx
      • Model1.Designer.cs
  • The Code Generator reads the CSDL (Conceptual Schema) and generates
    • an ObjectContext class based on the CSDL EntityContainer
      • Note: in this example, the ObjectContext will be called SampleEntities
    • Entity classes based on the EntityType
  • Obviously, for CodeFirst it's a bit changed:
    • an DbContext class based on the CSDL EntityContainer
    • etc…
<?xml version="1.0" encoding="utf-8"?>
<edmx:Edmx Version="2.0" xmlns:edmx="...">
  <edmx:Runtime>


    <!-- CSDL content -->
    <edmx:ConceptualModels>
      <Schema Namespace="SampleModel" Alias="Self"...>

        <EntityContainer Name="*SampleEntities*" annotation:LazyLoadingEnabled="true">
          <EntitySet></EntitySet>
          <AssociationSet Name="FK_Address_Contact" Association=""SampleModel.FK_Address_Contact">
            <End Role="Contact" EntitySet="Contacts">
            <End Role="Address" EntitySet="Addresses">
          </AssociationSet>
`       </EntityContainer>    
   
        <EntityType Name="Address" Type="SampleModel.Address">
          <Key>
            <EntityType Name="addressId"/>
          </Key>
          <Property Name "addressId" Type="Int32" Nullable="false"/>
          ...
          <NavigationProperty Name="Contact" 
                              Relationship="SampleModel.FK_Address_Contact"
                              FromRole="Address" ToRole="Contact"/>               
        </EntityType>
        ...
        <EntityType Name="Contact" Type="SampleModel.Contact">
          ...
        </EntityType>
        <AssociationType Name="FK_Address_Cont"/>
      </EntityContainer
    </Schema>
  </edmx:ConceptualModels>

    <!-- SSDL content -->
    <edmx:ConceptualModels>
      <EntityContainer>
        <EntitySet></EntitySet>
        <AssociationSet>...</AssociationSet>
      </EntityContainer>    
   
      <EntityType Name="Address">
        <Key>
          <EntityType Name="addressID"/>
        </Key>
        <Property Name "addressID" Type="int" Nullable="false"/>
        ...
        <!-- Note, no nav properties...-->
      </EntityType>
      ...
      <EntityType Name="Contact">
        ...
      </EntityType>
    </edmx:ConceptualModels>

   
   
  </edmx:Runtime>
</emdx:Edmx>
  • /home/skysigal/public_html/data/pages/it/ad/ef/concepts/edmx_file.txt
  • Last modified: 2023/11/04 22:57
  • by 127.0.0.1