实体数据模型的XML文件

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

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

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

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

  1. <span style="font-size:14px;"><?xml version="1.0" encoding="utf-8"?>
  2. <edmx:Edmx Version="2.0" xmlns:edmx="http://schemas.microsoft.com/ado/2008/10/edmx">
  3. <!-- EF Runtime content -->
  4. <edmx:Runtime>
  5. <!-- SSDL content -->
  6. <edmx:StorageModels>
  7. <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">
  8. <EntityContainer Name="OrderSystemModelStoreContainer">
  9. <EntitySet Name="UserAccounts" EntityType="OrderSystemModel.Store.UserAccounts" store:Type="Tables" Schema="dbo" />
  10. </EntityContainer>
  11. <EntityType Name="UserAccounts">
  12. <Key>
  13. <PropertyRef Name="Id" />
  14. </Key>
  15. <Property Name="FirstName" Type="nchar" Nullable="false" MaxLength="50" />
  16. <Property Name="LastName" Type="nchar" Nullable="false" MaxLength="50" />
  17. <Property Name="AuditFields_InsertDate" Type="datetime" Nullable="false" />
  18. <Property Name="AuditFields_UpdateDate" Type="datetime" Nullable="false" />
  19. <Property Name="Id" Type="int" Nullable="false" StoreGeneratedPattern="Identity" />
  20. </EntityType>
  21. <Function Name="UserAccounts_Delete" Aggregate="false" BuiltIn="false" NiladicFunction="false" IsComposable="false" ParameterTypeSemantics="AllowImplicitConversion" Schema="dbo">
  22. <Parameter Name="Id" Type="int" Mode="In" />
  23. </Function>
  24. <Function Name="UserAccounts_Insert" Aggregate="false" BuiltIn="false" NiladicFunction="false" IsComposable="false" ParameterTypeSemantics="AllowImplicitConversion" Schema="dbo">
  25. <Parameter Name="FirstName" Type="nvarchar" Mode="In" />
  26. <Parameter Name="LastName" Type="nvarchar" Mode="In" />
  27. <Parameter Name="AuditFields_InsertDate" Type="datetime" Mode="In" />
  28. <Parameter Name="AuditFields_UpdateDate" Type="datetime" Mode="In" />
  29. </Function>
  30. <Function Name="UserAccounts_SelectAll" Aggregate="false" BuiltIn="false" NiladicFunction="false" IsComposable="false" ParameterTypeSemantics="AllowImplicitConversion" Schema="dbo" />
  31. <Function Name="UserAccounts_SelectById" Aggregate="false" BuiltIn="false" NiladicFunction="false" IsComposable="false" ParameterTypeSemantics="AllowImplicitConversion" Schema="dbo">
  32. <Parameter Name="Id" Type="int" Mode="In" />
  33. </Function>
  34. <Function Name="UserAccounts_Update" Aggregate="false" BuiltIn="false" NiladicFunction="false" IsComposable="false" ParameterTypeSemantics="AllowImplicitConversion" Schema="dbo">
  35. <Parameter Name="Id" Type="int" Mode="In" />
  36. <Parameter Name="FirstName" Type="nvarchar" Mode="In" />
  37. <Parameter Name="LastName" Type="nvarchar" Mode="In" />
  38. <Parameter Name="AuditFields_UpdateDate" Type="datetime" Mode="In" />
  39. </Function>
  40. </Schema>
  41. </edmx:StorageModels>
  42. <!-- CSDL content -->
  43. <edmx:ConceptualModels>
  44. <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">
  45. <EntityContainer Name="OrderSystemEntities" annotation:LazyLoadingEnabled="true">
  46. <EntitySet Name="UserAccounts" EntityType="OrderSystemModel.UserAccounts" />
  47. <FunctionImport Name="UserAccounts_Delete">
  48. <Parameter Name="Id" Mode="In" Type="Int32" />
  49. </FunctionImport>
  50. <FunctionImport Name="UserAccounts_Insert" ReturnType="Collection(Int32)">
  51. <Parameter Name="FirstName" Mode="In" Type="String" />
  52. <Parameter Name="LastName" Mode="In" Type="String" />
  53. <Parameter Name="AuditFields_InsertDate" Mode="In" Type="DateTime" />
  54. <Parameter Name="AuditFields_UpdateDate" Mode="In" Type="DateTime" />
  55. </FunctionImport>
  56. </EntityContainer>
  57. <EntityType Name="UserAccounts">
  58. <Key>
  59. <PropertyRef Name="Id" />
  60. </Key>
  61. <Property Name="FirstName" Type="String" Nullable="false" MaxLength="50" Unicode="true" FixedLength="true" />
  62. <Property Name="LastName" Type="String" Nullable="false" MaxLength="50" Unicode="true" FixedLength="true" />
  63. <Property Name="AuditFields_InsertDate" Type="DateTime" Nullable="false" />
  64. <Property Name="AuditFields_UpdateDate" Type="DateTime" Nullable="false" />
  65. <Property Name="Id" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
  66. </EntityType>
  67. </Schema>
  68. </edmx:ConceptualModels>
  69. <!-- C-S mapping content -->
  70. <edmx:Mappings>
  71. <Mapping Space="C-S" xmlns="http://schemas.microsoft.com/ado/2008/09/mapping/cs">
  72. <EntityContainerMapping StorageEntityContainer="OrderSystemModelStoreContainer" CdmEntityContainer="OrderSystemEntities">
  73. <EntitySetMapping Name="UserAccounts"><EntityTypeMapping TypeName="OrderSystemModel.UserAccounts"><MappingFragment StoreEntitySet="UserAccounts">
  74. <ScalarProperty Name="FirstName" ColumnName="FirstName" />
  75. <ScalarProperty Name="LastName" ColumnName="LastName" />
  76. <ScalarProperty Name="AuditFields_InsertDate" ColumnName="AuditFields_InsertDate" />
  77. <ScalarProperty Name="AuditFields_UpdateDate" ColumnName="AuditFields_UpdateDate" />
  78. <ScalarProperty Name="Id" ColumnName="Id" />
  79. </MappingFragment></EntityTypeMapping></EntitySetMapping>
  80. <FunctionImportMapping FunctionImportName="UserAccounts_Delete" FunctionName="OrderSystemModel.Store.UserAccounts_Delete" />
  81. <FunctionImportMapping FunctionImportName="UserAccounts_Insert" FunctionName="OrderSystemModel.Store.UserAccounts_Insert" />
  82. </EntityContainerMapping>
  83. </Mapping>
  84. </edmx:Mappings>
  85. </edmx:Runtime>
  86. <!-- EF Designer content (DO NOT EDIT MANUALLY BELOW HERE) -->
  87. <Designer xmlns="http://schemas.microsoft.com/ado/2008/10/edmx">
  88. <Connection>
  89. <DesignerInfoPropertySet>
  90. <DesignerProperty Name="MetadataArtifactProcessing" Value="EmbedInOutputAssembly" />
  91. </DesignerInfoPropertySet>
  92. </Connection>
  93. <Options>
  94. <DesignerInfoPropertySet>
  95. <DesignerProperty Name="ValidateOnBuild" Value="true" />
  96. <DesignerProperty Name="EnablePluralization" Value="False" />
  97. <DesignerProperty Name="IncludeForeignKeysInModel" Value="True" />
  98. </DesignerInfoPropertySet>
  99. </Options>
  100. <!-- Diagram content (shape and connector positions) -->
  101. <Diagrams>
  102. <Diagram Name="OrderSystemModel">
  103. <EntityTypeShape EntityType="OrderSystemModel.UserAccounts" Width="1.5" PointX="0.75" PointY="0.75" Height="1.9700325520833331" IsExpanded="true" />
  104. </Diagram>
  105. </Diagrams>
  106. </Designer>
  107. </edmx:Edmx></span>
有过XML(可扩展标记语言)语言基础的可以从以上代码片段看出数据库表具有的具体字段以及实体类所具有的各个属性。看不懂的建议先学习一下XML(对学习EF无影响)。

猜你在找的XML相关文章