实体数据模型的XML文件

前端之家收集整理的这篇文章主要介绍了实体数据模型的XML文件前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

在EF中的实体数据模型(EDM)由以下三种模型和具有相应文件扩展名的映射文件进行定义。

  • 概念架构定义语言文件 (.csdl) -- 定义概念模型。R
  • 存储架构定义语言文件 (.ssdl) -- 定义存储模型(又称逻辑模型O)。
  • 映射规范语言文件 (.msl) -- 定义存储模型与概念模型之间的映射M。

实体框架 使用这些基于 XML 的模型和映射文件将对概念模型中的实体和关系的创建、读取、更新和删除操作转换为数据源中的等效操作。EDM 甚至支持将概念模型中的实体映射到数据源中的存储过程。用XML方式打开实体数据模型如下所示。

<span style="font-size:14px;"><?xml version="1.0" encoding="utf-8"?>
<edmx:Edmx Version="2.0" xmlns:edmx="http://schemas.microsoft.com/ado/2008/10/edmx">
  <!-- EF Runtime content -->
  <edmx:Runtime>
    <!-- SSDL content -->
    <edmx:StorageModels>
      <Schema Namespace="OrderSystemModel.Store" Alias="Self" Provider="System.Data.sqlClient" ProviderManifestToken="2008" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" xmlns="http://schemas.microsoft.com/ado/2009/02/edm/ssdl">
        <EntityContainer Name="OrderSystemModelStoreContainer">
          <EntitySet Name="UserAccounts" EntityType="OrderSystemModel.Store.UserAccounts" store:Type="Tables" Schema="dbo" />
        </EntityContainer>
        <EntityType Name="UserAccounts">
          <Key>
            <PropertyRef Name="Id" />
          </Key>
          <Property Name="FirstName" Type="nchar" Nullable="false" MaxLength="50" />
          <Property Name="LastName" Type="nchar" Nullable="false" MaxLength="50" />
          <Property Name="AuditFields_InsertDate" Type="datetime" Nullable="false" />
          <Property Name="AuditFields_UpdateDate" Type="datetime" Nullable="false" />
          <Property Name="Id" Type="int" Nullable="false" StoreGeneratedPattern="Identity" />
        </EntityType>
        <Function Name="UserAccounts_Delete" Aggregate="false" BuiltIn="false" NiladicFunction="false" IsComposable="false" ParameterTypeSemantics="AllowImplicitConversion" Schema="dbo">
          <Parameter Name="Id" Type="int" Mode="In" />
        </Function>
        <Function Name="UserAccounts_Insert" Aggregate="false" BuiltIn="false" NiladicFunction="false" IsComposable="false" ParameterTypeSemantics="AllowImplicitConversion" Schema="dbo">
          <Parameter Name="FirstName" Type="nvarchar" Mode="In" />
          <Parameter Name="LastName" Type="nvarchar" Mode="In" />
          <Parameter Name="AuditFields_InsertDate" Type="datetime" Mode="In" />
          <Parameter Name="AuditFields_UpdateDate" Type="datetime" Mode="In" />
        </Function>
        <Function Name="UserAccounts_SelectAll" Aggregate="false" BuiltIn="false" NiladicFunction="false" IsComposable="false" ParameterTypeSemantics="AllowImplicitConversion" Schema="dbo" />
        <Function Name="UserAccounts_SelectById" Aggregate="false" BuiltIn="false" NiladicFunction="false" IsComposable="false" ParameterTypeSemantics="AllowImplicitConversion" Schema="dbo">
          <Parameter Name="Id" Type="int" Mode="In" />
        </Function>
        <Function Name="UserAccounts_Update" Aggregate="false" BuiltIn="false" NiladicFunction="false" IsComposable="false" ParameterTypeSemantics="AllowImplicitConversion" Schema="dbo">
          <Parameter Name="Id" Type="int" Mode="In" />
          <Parameter Name="FirstName" Type="nvarchar" Mode="In" />
          <Parameter Name="LastName" Type="nvarchar" Mode="In" />
          <Parameter Name="AuditFields_UpdateDate" Type="datetime" Mode="In" />
        </Function>
      </Schema>
    </edmx:StorageModels>
    <!-- CSDL content -->
    <edmx:ConceptualModels>
      <Schema Namespace="OrderSystemModel" Alias="Self" xmlns:annotation="http://schemas.microsoft.com/ado/2009/02/edm/annotation" xmlns="http://schemas.microsoft.com/ado/2008/09/edm">
        <EntityContainer Name="OrderSystemEntities" annotation:LazyLoadingEnabled="true">
          <EntitySet Name="UserAccounts" EntityType="OrderSystemModel.UserAccounts" />
          <FunctionImport Name="UserAccounts_Delete">
            <Parameter Name="Id" Mode="In" Type="Int32" />
          </FunctionImport>
          <FunctionImport Name="UserAccounts_Insert" ReturnType="Collection(Int32)">
            <Parameter Name="FirstName" Mode="In" Type="String" />
            <Parameter Name="LastName" Mode="In" Type="String" />
            <Parameter Name="AuditFields_InsertDate" Mode="In" Type="DateTime" />
            <Parameter Name="AuditFields_UpdateDate" Mode="In" Type="DateTime" />
          </FunctionImport>
        </EntityContainer>
        <EntityType Name="UserAccounts">
          <Key>
            <PropertyRef Name="Id" />
          </Key>
          <Property Name="FirstName" Type="String" Nullable="false" MaxLength="50" Unicode="true" FixedLength="true" />
          <Property Name="LastName" Type="String" Nullable="false" MaxLength="50" Unicode="true" FixedLength="true" />
          <Property Name="AuditFields_InsertDate" Type="DateTime" Nullable="false" />
          <Property Name="AuditFields_UpdateDate" Type="DateTime" Nullable="false" />
          <Property Name="Id" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
        </EntityType>
      </Schema>
    </edmx:ConceptualModels>
    <!-- C-S mapping content -->
    <edmx:Mappings>
      <Mapping Space="C-S" xmlns="http://schemas.microsoft.com/ado/2008/09/mapping/cs">
        <EntityContainerMapping StorageEntityContainer="OrderSystemModelStoreContainer" CdmEntityContainer="OrderSystemEntities">
          <EntitySetMapping Name="UserAccounts"><EntityTypeMapping TypeName="OrderSystemModel.UserAccounts"><MappingFragment StoreEntitySet="UserAccounts">
            <ScalarProperty Name="FirstName" ColumnName="FirstName" />
            <ScalarProperty Name="LastName" ColumnName="LastName" />
            <ScalarProperty Name="AuditFields_InsertDate" ColumnName="AuditFields_InsertDate" />
            <ScalarProperty Name="AuditFields_UpdateDate" ColumnName="AuditFields_UpdateDate" />
            <ScalarProperty Name="Id" ColumnName="Id" />
          </MappingFragment></EntityTypeMapping></EntitySetMapping>
          <FunctionImportMapping FunctionImportName="UserAccounts_Delete" FunctionName="OrderSystemModel.Store.UserAccounts_Delete" />
          <FunctionImportMapping FunctionImportName="UserAccounts_Insert" FunctionName="OrderSystemModel.Store.UserAccounts_Insert" />
        </EntityContainerMapping>
      </Mapping>
    </edmx:Mappings>
  </edmx:Runtime>
  <!-- EF Designer content (DO NOT EDIT MANUALLY BELOW HERE) -->
  <Designer xmlns="http://schemas.microsoft.com/ado/2008/10/edmx">
    <Connection>
      <DesignerInfoPropertySet>
        <DesignerProperty Name="MetadataArtifactProcessing" Value="EmbedInOutputAssembly" />
      </DesignerInfoPropertySet>
    </Connection>
    <Options>
      <DesignerInfoPropertySet>
        <DesignerProperty Name="ValidateOnBuild" Value="true" />
        <DesignerProperty Name="EnablePluralization" Value="False" />
        <DesignerProperty Name="IncludeForeignKeysInModel" Value="True" />
      </DesignerInfoPropertySet>
    </Options>
    <!-- Diagram content (shape and connector positions) -->
    <Diagrams>
      <Diagram Name="OrderSystemModel">
        <EntityTypeShape EntityType="OrderSystemModel.UserAccounts" Width="1.5" PointX="0.75" PointY="0.75" Height="1.9700325520833331" IsExpanded="true" />
      </Diagram>
    </Diagrams>
  </Designer>
</edmx:Edmx></span>
有过XML(可扩展标记语言)语言基础的可以从以上代码片段看出数据库表具有的具体字段以及实体类所具有的各个属性。看不懂的建议先学习一下XML(对学习EF无影响)。 原文链接:https://www.f2er.com/xml/297547.html

猜你在找的XML相关文章