Entity Framework

ADO.NET Entity Framework 是微软提供了一个ORM框架。

概念架构定义语言:(CSDL:Conceptual Schema Definition Language)。

存储架构定义语言:(SSDL:Storage Schema Definition Language)。

映射架构语言:(MSL:Mapping Schema Language)。

<?xml version="1.0" encoding="utf-8"?>
        <Schema Namespace="BooksModel.Store" Provider="System.Data.SqlClient" ProviderManifestToken="2008" Alias="Self" xmlns="">   <EntityType Name="Authors">     <Key>       <PropertyRef Name="Id" />     </Key>     <Property Name="Id" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />     <Property Name="FirstName" Type="nvarchar" MaxLength="50" Nullable="false" />     <Property Name="LastName" Type="nvarchar" MaxLength="50" Nullable="false" />   </EntityType>   <EntityType Name="Books">     <Key>       <PropertyRef Name="Id" />     </Key>     <Property Name="Id" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />     <Property Name="Title" Type="nvarchar" MaxLength="50" Nullable="false" />     <Property Name="Publisher" Type="nvarchar" MaxLength="50" Nullable="false" />     <Property Name="Isbn" Type="nvarchar" MaxLength="50" Nullable="false" />   </EntityType>   <EntityType Name="BooksAuthors">     <Key>       <PropertyRef Name="Authors_Id" />       <PropertyRef Name="Books_Id" />     </Key>     <Property Name="Authors_Id" Type="int" Nullable="false" />     <Property Name="Books_Id" Type="int" Nullable="false" />   </EntityType>   <Association Name="FK_BooksAuthors_ToAuthors">     <End Role="Authors" Type="Self.Authors" Multiplicity="1" />     <End Role="BooksAuthors" Type="Self.BooksAuthors" Multiplicity="*" />     <ReferentialConstraint>       <Principal Role="Authors">         <PropertyRef Name="Id" />       </Principal>       <Dependent Role="BooksAuthors">         <PropertyRef Name="Authors_Id" />       </Dependent>     </ReferentialConstraint>   </Association>   <Association Name="FK_BooksAuthors_ToBooks">     <End Role="Books" Type="Self.Books" Multiplicity="1" />     <End Role="BooksAuthors" Type="Self.BooksAuthors" Multiplicity="*" />     <ReferentialConstraint>       <Principal Role="Books">         <PropertyRef Name="Id" />       </Principal>       <Dependent Role="BooksAuthors">         <PropertyRef Name="Books_Id" />       </Dependent>     </ReferentialConstraint>   </Association>   <EntityContainer Name="BooksModelStoreContainer">     <EntitySet Name="Authors" EntityType="Self.Authors" Schema="dbo" p3:Type="Tables" xmlns:p3="" />     <EntitySet Name="Books" EntityType="Self.Books" Schema="dbo" p3:Type="Tables" xmlns:p3="" />     <EntitySet Name="BooksAuthors" EntityType="Self.BooksAuthors" Schema="dbo" p3:Type="Tables" xmlns:p3="" />     <AssociationSet Name="FK_BooksAuthors_ToAuthors" Association="Self.FK_BooksAuthors_ToAuthors">       <End Role="Authors" EntitySet="Authors" />       <End Role="BooksAuthors" EntitySet="BooksAuthors" />     </AssociationSet>     <AssociationSet Name="FK_BooksAuthors_ToBooks" Association="Self.FK_BooksAuthors_ToBooks">       <End Role="Books" EntitySet="Books" />       <End Role="BooksAuthors" EntitySet="BooksAuthors" />     </AssociationSet>   </EntityContainer>
        </Schema>

使用ADO.NET Entity Framework 需要定义的层:

逻辑层:使用存储架构定义语言SSDL定义关系数据,用来描述数据表及表间关联关系的架构。

posted @ 2016-01-21 10:48  qing_sun  阅读(138)  评论(0编辑  收藏  举报