HOW TO:使用每個類型的資料表繼承來定義模型 (Entity Framework)
在 實體資料模型 (EDM) 中,您可以使用幾種方式來實作繼承。每個類型的資料表方法會在儲存區中使用個別資料表來維護繼承階層中每一個型別的資料。本章節含有在每個類型的資料表案例上實作之簡易繼承階層的結構描述和對應。
在 EDM 中,每個類型的資料表模型上適用於繼承階層架構的概念結構描述會針對衍生型別 (Derived Type) 的宣告包含 BaseType 屬性指派。每一個衍生的 EntityType 都會單獨宣告,但是 EntityContainer 的宣告只包含基底類型的 EntitySet 宣告。
這個案例中的關聯是在基底類型上實作,因為關聯的定義會參考 EntitySet 宣告。衍生型別 (Derived Type) 在 EntityContainer 中沒有任何 EntitySet 宣告。
若要為每個類型的資料表繼承實作概念結構描述
建立類別庫 (Class Library) 專案。
按一下 [加入新項目],然後加入 [ADO.NET 實體資料模型]。
當精靈出現時建立空白模型。
以 [xml 編輯器] 開啟 .edmx 檔案,加入該檔案的概念結構定義語言 (xml) 區段。
實作 CSDL 結構描述。此結構描述包含稱為 SchoolDataLib 之命名空間中的宣告。繼承階層包含名為 Department 的 EntityType (這是基底類型) 以及 business、engineering 和 music 科系的三個衍生實體。只有基底類型 Department 具有 Key 屬性指派。衍生型別 DeptBusiness、DeptEngineering 和 DeptMusic 包含 BaseType 屬性指派。代表儲存區中衍生型別之資料表的 Key 資料行全都會對應到代表基底類型之資料表的 Key 資料行。
在 Department 和 Person 實體之間實作 AssociationType。此關聯會用於 SchoolAdministrator 之導覽屬性的實作。FK_Department_Administrator 會定義衍生自其宣告所在之 Department 型別的所有型別所使用的關聯。使用這個 AssociationType 的 NavigationProperty 會由所有衍生型別所繼承。完整的 CSDL 結構描述如下所示。
<!-- CSDL content -->
<Schema
xmlns="https://schemas.microsoft.com/ado/2006/04/edm"
Namespace="SchoolDataLib"
Alias="Self">
<EntityType Name="Department">
<!--Base type table-per-type inheritance-->
<Key>
<PropertyRef Name="DepartmentID" />
</Key>
<Property Name="DepartmentID" Type="Int32" Nullable="false" />
<Property Name="Name" Type="String" Nullable="false" />
<Property Name="Budget" Type="Decimal" Nullable="false" />
<Property Name="StartDate" Type="DateTime" Nullable="false" />
<NavigationProperty Name="Administrator"
Relationship="SchoolDataLib.FK_Department_Administrator"
FromRole="Department" ToRole="Person" />
</EntityType>
<EntityType Name="DeptBusiness" BaseType="SchoolDataLib.Department">
<Property Name="LegalBudget" Type="Decimal" Nullable="false" />
<Property Name="AccountingBudget" Type="Decimal" Nullable="false" />
</EntityType>
<EntityType Name="DeptEngineering" BaseType="SchoolDataLib.Department">
<Property Name="FiberOpticsBudget" Type="Decimal" Nullable="false" />
<Property Name="LabBudget" Type="Decimal" Nullable="false" />
</EntityType>
<EntityType Name="DeptMusic" BaseType="SchoolDataLib.Department">
<Property Name="TheaterBudget" Type="Decimal" Nullable="false" />
<Property Name="InstrumentBudget" Type="Decimal" Nullable="false" />
</EntityType>
<Association Name="FK_Department_Administrator">
<End Role="Person" Type="SchoolDataLib.Person" Multiplicity="0..1" />
<End Role="Department" Type="SchoolDataLib.Department" Multiplicity="*" />
</Association>
<EntityType Name="Person">
<!--Base type table-per-hierarchy inheritance-->
<Key>
<PropertyRef Name="PersonID" />
</Key>
<Property Name="PersonID" Type="Int32" Nullable="false" />
<Property Name="FirstName" Type="String" Nullable="false" />
<Property Name="LastName" Type="String" Nullable="false" />
<NavigationProperty Name="Department"
Relationship="SchoolDataLib.FK_Department_Administrator"
FromRole="Person" ToRole="Department" />
</EntityType>
<EntityType Name="Student" BaseType="SchoolDataLib.Person">
<Property Name="EnrollmentDate" Type="DateTime" />
</EntityType>
<EntityType Name="Instructor" BaseType="SchoolDataLib.Person">
<Property Name="HireDate" Type="DateTime" />
</EntityType>
<EntityType Name="Administrator" BaseType="SchoolDataLib.Person">
<Property Name="AdminDate" Type="DateTime" />
</EntityType>
<EntityContainer Name="SchoolDataLibContainer">
<EntitySet Name="Departments" EntityType="SchoolDataLib.Department" />
<EntitySet Name="People" EntityType="SchoolDataLib.Person" />
<AssociationSet Name="FK_Department_Administrator"
Association="SchoolDataLib.FK_Department_Administrator">
<End Role="Person" EntitySet="People" />
<End Role="Department" EntitySet="Departments" />
</AssociationSet>
</EntityContainer>
</Schema>
若要為每個類型的資料表繼承實作儲存區結構描述
在 .edmx 檔案的存放結構定義語言 (SSDL) 區段中為繼承階層架構內的每個類型定義含有資料的資料表。儲存體模型中衍生型別的實體具有 Key 屬性,與概念結構描述中的實體宣告不同。
請針對儲存結構描述中的屬性使用資料庫管理系統的資料型別,而非概念結構描述中所使用的 Common Language Runtime (CLR) 型別。
使用 SSDL 的下列語法來定義此繼承案例中使用的完整儲存區中繼資料。
<!-- SSDL content -->
<Schema
xmlns="https://schemas.microsoft.com/ado/2006/04/edm/ssdl"
Namespace="SchoolDataLib.Target"
Provider="System.Data.SqlClient"
ProviderManifestToken="2005"
Alias="Self">
<EntityContainer Name="dbo">
<EntitySet Name="Department" EntityType="SchoolDataLib.Target.Department" />
<EntitySet Name="DeptBusiness" EntityType="SchoolDataLib.Target.DeptBusiness" />
<EntitySet Name="DeptEngineering" EntityType="SchoolDataLib.Target.DeptEngineering" />
<EntitySet Name="DeptMusic" EntityType="SchoolDataLib.Target.DeptMusic" />
<EntitySet Name="Person" EntityType="SchoolDataLib.Target.Person" />
<AssociationSet Name="FK_Department_Administrator"
Association="SchoolDataLib.Target.FK_Department_Administrator">
<End Role="Person" EntitySet="Person" />
<End Role="Department" EntitySet="Department" />
</AssociationSet>
</EntityContainer>
<EntityType Name="Department">
<Key>
<PropertyRef Name="DepartmentID" />
</Key>
<Property Name="DepartmentID" Type="int" Nullable="false" />
<Property Name="Name" Type="nvarchar" Nullable="false" MaxLength="50" />
<Property Name="Budget" Type="money" Nullable="false" />
<Property Name="StartDate" Type="datetime" Nullable="false" />
<Property Name="Administrator" Type="int" />
</EntityType>
<EntityType Name="DeptBusiness">
<Key>
<PropertyRef Name="BusinessDeptID" />
</Key>
<Property Name="BusinessDeptID" Type="int" Nullable="false" />
<Property Name="LegalBudget" Type="money" Nullable="false" />
<Property Name="AccountingBudget" Type="money" Nullable="false" />
</EntityType>
<EntityType Name="DeptEngineering">
<Key>
<PropertyRef Name="EngineeringDeptID" />
</Key>
<Property Name="EngineeringDeptID" Type="int" Nullable="false" />
<Property Name="FiberOpticsBudget" Type="money" Nullable="false" />
<Property Name="LabBudget" Type="money" Nullable="false" />
</EntityType>
<EntityType Name="DeptMusic">
<Key>
<PropertyRef Name="DeptMusicID" />
</Key>
<Property Name="DeptMusicID" Type="int" Nullable="false" />
<Property Name="TheaterBudget" Type="money" Nullable="false" />
<Property Name="InstrumentBudget" Type="money" Nullable="false" />
</EntityType>
<EntityType Name="Person">
<Key>
<PropertyRef Name="PersonID" />
</Key>
<Property Name="PersonID" Type="int" Nullable="false" />
<Property Name="FirstName" Type="nvarchar" Nullable="false" MaxLength="50" />
<Property Name="LastName" Type="nvarchar" Nullable="false" MaxLength="50" />
<Property Name="HireDate" Type="datetime" />
<Property Name="EnrollmentDate" Type="datetime" />
<Property Name="AdminDate" Type="datetime" />
<Property Name="PersonCategory" Type="smallint" Nullable="false" />
</EntityType>
<Association Name="FK_Department_Administrator">
<End Role="Person" Type="SchoolDataLib.Target.Person" Multiplicity="0..1" />
<End Role="Department" Type="SchoolDataLib.Target.Department" Multiplicity="*" />
<ReferentialConstraint>
<Principal Role="Person">
<PropertyRef Name="PersonID" />
</Principal>
<Dependent Role="Department">
<PropertyRef Name="Administrator" />
</Dependent>
</ReferentialConstraint>
</Association>
</Schema>
若要使用 SQL Server Management Studio 來產生資料庫
搭配 SQL Server Management Studio 使用下列指令碼,以產生這個範例以及 HOW TO:使用每個階層的資料表繼承來定義模型 (Entity Framework) 範例中所用的資料庫。
指向 [檔案] 功能表上的 [新增],然後按一下 [Database Engine 查詢]。
在 [連接到 Database Engine] 對話方塊中,輸入 localhost 或另一個 SQL Server 執行個體的名稱,然後按一下 [連接]。
將下列 Transact-SQL 指令碼貼入查詢視窗中,然後按一下 [執行]。
USE [master]
GO
CREATE DATABASE [SchoolData]
GO
USE [SchoolData]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[DeptBusiness]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[DeptBusiness](
[BusinessDeptID] [int] NOT NULL,
[LegalBudget] [money] NOT NULL,
[AccountingBudget] [money] NOT NULL,
CONSTRAINT [PK_DeptBusiness] PRIMARY KEY CLUSTERED
(
[BusinessDeptID] ASC
)WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[DeptEngineering]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[DeptEngineering](
[EngineeringDeptID] [int] NOT NULL,
[FiberOpticsBudget] [money] NOT NULL,
[LabBudget] [money] NOT NULL,
CONSTRAINT [PK_DeptEngineering] PRIMARY KEY CLUSTERED
(
[EngineeringDeptID] ASC
)WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[DeptMusic]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[DeptMusic](
[DeptMusicID] [int] NOT NULL,
[TheaterBudget] [money] NOT NULL,
[InstrumentBudget] [money] NOT NULL,
CONSTRAINT [PK_DeptMusic] PRIMARY KEY CLUSTERED
(
[DeptMusicID] ASC
)WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Course]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[Course](
[CourseID] [int] NOT NULL,
[Title] [nvarchar](100) NOT NULL,
[StartDate] [datetime] NOT NULL,
[EndDate] [datetime] NOT NULL,
[Credits] [int] NULL,
CONSTRAINT [PK_Course] PRIMARY KEY CLUSTERED
(
[CourseID] ASC
)WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Person]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[Person](
[PersonID] [int] NOT NULL,
[FirstName] [nvarchar](50) NOT NULL,
[LastName] [nvarchar](50) NOT NULL,
[HireDate] [datetime] NULL,
[EnrollmentDate] [datetime] NULL,
[PersonCategory] [smallint] NOT NULL,
[AdminDate] [datetime] NULL,
CONSTRAINT [PK_Person] PRIMARY KEY CLUSTERED
(
[PersonID] ASC
)WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Enrollment]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[Enrollment](
[EnrollmentID] [int] NOT NULL,
[CourseID] [int] NOT NULL,
[StudentID] [int] NOT NULL,
CONSTRAINT [PK_Enrollment] PRIMARY KEY CLUSTERED
(
[EnrollmentID] ASC
)WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[CourseInstructor]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[CourseInstructor](
[CourseInstructorID] [int] NOT NULL,
[CourseID] [int] NOT NULL,
[InstructorID] [int] NOT NULL,
CONSTRAINT [PK_CourseInstructor] PRIMARY KEY CLUSTERED
(
[CourseInstructorID] ASC
)WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Department]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[Department](
[DepartmentID] [int] NOT NULL,
[Name] [nvarchar](50) NOT NULL,
[Budget] [money] NOT NULL,
[StartDate] [datetime] NOT NULL,
[Administrator] [int] NULL,
CONSTRAINT [PK_Department] PRIMARY KEY CLUSTERED
(
[DepartmentID] ASC
)WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Enrollment_Course]') AND parent_object_id = OBJECT_ID(N'[dbo].[Enrollment]'))
ALTER TABLE [dbo].[Enrollment] WITH CHECK ADD CONSTRAINT [FK_Enrollment_Course] FOREIGN KEY([CourseID])
REFERENCES [dbo].[Course] ([CourseID])
GO
ALTER TABLE [dbo].[Enrollment] CHECK CONSTRAINT [FK_Enrollment_Course]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Enrollment_Student]') AND parent_object_id = OBJECT_ID(N'[dbo].[Enrollment]'))
ALTER TABLE [dbo].[Enrollment] WITH CHECK ADD CONSTRAINT [FK_Enrollment_Student] FOREIGN KEY([StudentID])
REFERENCES [dbo].[Person] ([PersonID])
GO
ALTER TABLE [dbo].[Enrollment] CHECK CONSTRAINT [FK_Enrollment_Student]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CourseInstructor_Course]') AND parent_object_id = OBJECT_ID(N'[dbo].[CourseInstructor]'))
ALTER TABLE [dbo].[CourseInstructor] WITH CHECK ADD CONSTRAINT [FK_CourseInstructor_Course] FOREIGN KEY([CourseID])
REFERENCES [dbo].[Course] ([CourseID])
GO
ALTER TABLE [dbo].[CourseInstructor] CHECK CONSTRAINT [FK_CourseInstructor_Course]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CourseInstructor_Instructor]') AND parent_object_id = OBJECT_ID(N'[dbo].[CourseInstructor]'))
ALTER TABLE [dbo].[CourseInstructor] WITH CHECK ADD CONSTRAINT [FK_CourseInstructor_Instructor] FOREIGN KEY([InstructorID])
REFERENCES [dbo].[Person] ([PersonID])
GO
ALTER TABLE [dbo].[CourseInstructor] CHECK CONSTRAINT [FK_CourseInstructor_Instructor]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Department_Administrator]') AND parent_object_id = OBJECT_ID(N'[dbo].[Department]'))
ALTER TABLE [dbo].[Department] WITH CHECK ADD CONSTRAINT [FK_Department_Administrator] FOREIGN KEY([Administrator])
REFERENCES [dbo].[Person] ([PersonID])
GO
ALTER TABLE [dbo].[Department] CHECK CONSTRAINT [FK_Department_Administrator]
若要為每個類型的資料表繼承實作對應規格
針對基底類型之 EntitySet 對應底下的衍生型別結合 EntityTypeMapping 標記。在下列對應規格語言 (MSL) 結構描述中,EntitySet 會命名為 Departments (如同概念結構描述中所定義)。
在基底類型和衍生型別的 EntitySet 對應之下使用 EntityTypeMapping。
指定由 TypeName 屬性在 EntityTypeMapping 之下對應的每一個型別。
遵循具有 TableMappingFragment 的 TableName 屬性。
使用 ScalarProperty 標記將實體類型的屬性對應到儲存中繼資料內指定的資料行。
請注意,衍生型別的識別資料行全都會對應到基底類型的識別屬性,在此案例中,這個屬性命名為 DepartmentID。
透過 Department 基底類別,使用下列 MSL 語法來對應 EntitySet。
為每一個衍生型別指定 EntityTypeMapping。
<!-- C-S mapping content -->
<Mapping xmlns="urn:schemas-microsoft-com:windows:storage:mapping:CS"
Space="C-S">
<Alias Key="Model" Value="SchoolDataLib" />
<Alias Key="Target" Value="SchoolDataLib.Target" />
<EntityContainerMapping CdmEntityContainer="SchoolDataLibContainer"
StorageEntityContainer="dbo">
<!-- Mapping for table-per-type inheritance-->
<EntitySetMapping Name="Departments">
<EntityTypeMapping
TypeName="IsTypeOf(SchoolDataLib.Department)">
<MappingFragment StoreEntitySet="Department">
<ScalarProperty
Name="DepartmentID" ColumnName="DepartmentID" />
<ScalarProperty Name="Name" ColumnName="Name" />
<ScalarProperty Name="Budget" ColumnName="Budget" />
<ScalarProperty
Name="StartDate" ColumnName="StartDate" />
</MappingFragment>
</EntityTypeMapping>
<EntityTypeMapping TypeName="SchoolDataLib.DeptBusiness">
<MappingFragment StoreEntitySet="DeptBusiness">
<ScalarProperty Name="DepartmentID"
ColumnName="BusinessDeptID" />
<ScalarProperty Name="AccountingBudget"
ColumnName="AccountingBudget" />
<ScalarProperty Name="LegalBudget"
ColumnName="LegalBudget" />
</MappingFragment>
</EntityTypeMapping>
<EntityTypeMapping TypeName="SchoolDataLib.DeptEngineering">
<MappingFragment StoreEntitySet="DeptEngineering">
<ScalarProperty Name="DepartmentID"
ColumnName="EngineeringDeptID" />
<ScalarProperty Name="FiberOpticsBudget"
ColumnName="FiberOpticsBudget" />
<ScalarProperty Name="LabBudget"
ColumnName="LabBudget" />
</MappingFragment>
</EntityTypeMapping>
<EntityTypeMapping TypeName="SchoolDataLib.DeptMusic">
<MappingFragment StoreEntitySet="DeptMusic">
<ScalarProperty Name="DepartmentID"
ColumnName="DeptMusicID" />
<ScalarProperty Name="TheaterBudget"
ColumnName="TheaterBudget" />
<ScalarProperty Name="InstrumentBudget"
ColumnName="InstrumentBudget" />
</MappingFragment>
</EntityTypeMapping>
</EntitySetMapping>
<!--Mapping for table-per-hierarchy inheritance-->
<EntitySetMapping Name="People">
<EntityTypeMapping TypeName="SchoolDataLib.Person">
<MappingFragment StoreEntitySet="Person">
<ScalarProperty Name="PersonID" ColumnName="PersonID"/>
<ScalarProperty Name="FirstName" ColumnName="FirstName"/>
<ScalarProperty Name="LastName" ColumnName="LastName"/>
<Condition ColumnName="PersonCategory" Value="0" />
</MappingFragment>
</EntityTypeMapping>
<EntityTypeMapping TypeName="SchoolDataLib.Student">
<MappingFragment StoreEntitySet="Person">
<ScalarProperty Name="PersonID" ColumnName="PersonID" />
<ScalarProperty Name="FirstName" ColumnName="FirstName" />
<ScalarProperty Name="LastName" ColumnName="LastName" />
<ScalarProperty
Name="EnrollmentDate" ColumnName="EnrollmentDate" />
<Condition ColumnName="PersonCategory" Value="1" />
</MappingFragment>
</EntityTypeMapping>
<EntityTypeMapping TypeName="SchoolDataLib.Instructor">
<MappingFragment StoreEntitySet="Person">
<ScalarProperty Name="PersonID" ColumnName="PersonID" />
<ScalarProperty Name="FirstName" ColumnName="FirstName" />
<ScalarProperty Name="LastName" ColumnName="LastName" />
<ScalarProperty Name="HireDate" ColumnName="HireDate" />
<Condition ColumnName="PersonCategory" Value="2" />
</MappingFragment>
</EntityTypeMapping>
<EntityTypeMapping TypeName="SchoolDataLib.Administrator">
<MappingFragment StoreEntitySet="Person">
<ScalarProperty Name="PersonID" ColumnName="PersonID" />
<ScalarProperty Name="FirstName" ColumnName="FirstName" />
<ScalarProperty Name="LastName" ColumnName="LastName" />
<ScalarProperty Name="AdminDate" ColumnName="AdminDate" />
<Condition ColumnName="PersonCategory" Value="3" />
</MappingFragment>
</EntityTypeMapping>
</EntitySetMapping>
<AssociationSetMapping Name="FK_Department_Administrator"
TypeName="SchoolDataLib.FK_Department_Administrator"
StoreEntitySet="Department">
<EndProperty Name="Person">
<ScalarProperty Name="PersonID" ColumnName="Administrator" />
</EndProperty>
<EndProperty Name="Department">
<ScalarProperty Name="DepartmentID" ColumnName="DepartmentID" />
</EndProperty>
<Condition ColumnName="Administrator" IsNull="false" />
</AssociationSetMapping>
</EntityContainerMapping>
</Mapping>
另請參閱
工作
HOW TO:使用每個類型的資料表繼承來定義模型 (Entity Framework)
HOW TO:加入及修改具有每個類型的資料表繼承的物件 (Entity Framework)
HOW TO:使用每個階層的資料表繼承來定義模型 (Entity Framework)