AdventureWorks 完整模型 (EDM)

很多基于 实体数据模型 (EDM) 的应用程序都需要将架构映射到已在使用的数据库。完成概念设计后,映射到现有数据比实现存储模型更为复杂。

SQL Server 中包含的 AdventureWorks 数据库是一个旨在演示 SQL Server 功能的大型规范化数据库。AdventureWorks 数据库有五个子部分,所有这些部分都可以使用概念架构定义语言 (CSDL) 在单个 EntityContainer 中指定。存储模型是使用存储架构定义语言 (SSDL) 中的元数据描述的。概念架构和存储架构之间的映射是使用映射规范语言 (MSL) 完成的。

以下主题中的所有架构都是由命令行工具 EdmGen.exe 生成的。使用的单个命令语法包括 /FullGeneration 和 /Project:AdventureWorks、/Provider 开关以及到 AdventureWorks 数据库的连接字符串。

C:\>%windir%\Microsoft.NET\Framework\v3.5\edmgen.exe /mode:fullgeneration /project:AdventureWorks
 /provider:System.Data.SqlClient 
/connectionstring:"server=.\sqlExpress;
integrated security=true;database=AdventureWorks" /outssdl:c:\BuildSchemas\AdventureWorks.ssdl /outcsdl:c:\BuildSchemas\AdventureWorks.csdl 
/outmsl:c:\BuildSchemas\AdventureWorks.msl 
/outViews:c:\BuildSchemas\AdventureWorks.Views.cs
 /outObjectLayer:c:\BuildSchemas\AdventureWorks.ObjectLayer.cs

这种大型数据库的架构是使用工具正确生成的。CSDL 架构是用于为 AdventureWorks 数据库的所有其他功能生成可编程对象的规范。输出如下所示。

Microsoft ® EdmGen version 3.5.0.0
Copyright © Microsoft Corporation 2007. All rights reserved.

Loading database information...
warning 6002: The table/view 'AdventureWorks.HumanResources.vEmployee' does not
have a primary key defined. The key has been inferred and the definition was cre
ated as a read-only table/view.
warning 6002: The table/view 'AdventureWorks.HumanResources.vEmployeeDepartment'
 does not have a primary key defined. The key has been inferred and the definiti
on was created as a read-only table/view.
warning 6002: The table/view 'AdventureWorks.HumanResources.vEmployeeDepartmentH
istory' does not have a primary key defined. The key has been inferred and the d
efinition was created as a read-only table/view.
warning 6002: The table/view 'AdventureWorks.HumanResources.vJobCandidate' does
not have a primary key defined. The key has been inferred and the definition was
 created as a read-only table/view.
warning 6002: The table/view 'AdventureWorks.HumanResources.vJobCandidateEducati
on' does not have a primary key defined. The key has been inferred and the defin
ition was created as a read-only table/view.
warning 6002: The table/view 'AdventureWorks.HumanResources.vJobCandidateEmploym
ent' does not have a primary key defined. The key has been inferred and the defi
nition was created as a read-only table/view.
warning 6002: The table/view 'AdventureWorks.Person.vAdditionalContactInfo' does
 not have a primary key defined. The key has been inferred and the definition wa
s created as a read-only table/view.
warning 6002: The table/view 'AdventureWorks.Person.vStateProvinceCountryRegion'
 does not have a primary key defined. The key has been inferred and the definiti
on was created as a read-only table/view.
warning 6002: The table/view 'AdventureWorks.Production.vProductAndDescription'
does not have a primary key defined. The key has been inferred and the definitio
n was created as a read-only table/view.
warning 6002: The table/view 'AdventureWorks.Production.vProductModelCatalogDesc
ription' does not have a primary key defined. The key has been inferred and the
definition was created as a read-only table/view.
warning 6002: The table/view 'AdventureWorks.Production.vProductModelInstruction
s' does not have a primary key defined. The key has been inferred and the defini
tion was created as a read-only table/view.
warning 6002: The table/view 'AdventureWorks.Purchasing.vVendor' does not have a
 primary key defined. The key has been inferred and the definition was created a
s a read-only table/view.
warning 6002: The table/view 'AdventureWorks.Sales.vIndividualCustomer' does not
 have a primary key defined. The key has been inferred and the definition was cr
eated as a read-only table/view.
warning 6002: The table/view 'AdventureWorks.Sales.vIndividualDemographics' does
 not have a primary key defined. The key has been inferred and the definition wa
s created as a read-only table/view.
warning 6002: The table/view 'AdventureWorks.Sales.vSalesPerson' does not have a
 primary key defined. The key has been inferred and the definition was created a
s a read-only table/view.
warning 6002: The table/view 'AdventureWorks.Sales.vSalesPersonSalesByFiscalYear
s' does not have a primary key defined. The key has been inferred and the defini
tion was created as a read-only table/view.
warning 6002: The table/view 'AdventureWorks.Sales.vStoreWithDemographics' does
not have a primary key defined. The key has been inferred and the definition was
 created as a read-only table/view.
Writing ssdl file...
Creating conceptual layer from storage layer...
Writing msl file...
Writing csdl file...
Writing object layer file...
Writing views file...

Generation Complete -- 0 errors, 17 warnings

本节内容

下列主题包含 AdventureWorks 数据的架构和映射。

另请参见

其他资源

EDM 规范
架构和映射规范(实体框架)
架构和映射规范(实体框架)