Поделиться через


Полная модель AdventureWorks (модель EDM)

Многим приложениям, которые основаны на модели Entity Data Model (EDM), требуются схемы сопоставления с базой данных, которая уже используется. Сопоставление с существующими данными — более сложная задача, чем реализация модели хранения после завершения концептуального проектирования.

База данных AdventureWorks, которая поставляется с SQL Server, — это большая нормализованная база данных, предназначенная для демонстрации функций SQL Server. Имеется пять подразделов базы данных AdventureWorks, и все они могут быть определены в одном контейнере EntityContainer на языке CSDL. В языке SSDL модель хранения описывается метаданными. Сопоставление концептуальной схемы и схемы хранения выполняется при помощи языка MSL.

В следующих подразделах все схемы были сформированы средством командной строки EdmGen.exe. В синтаксисе единственной используемой при этом команды предусмотрены параметры /FullGeneration, /Project:Adventureworks и /Provide, а также строка соединения с базой данных 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 (R) EdmGen version 3.5.0.0
Copyright (C) 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
Спецификация схем и сопоставлений (платформа Entity Framework)
Спецификация схем и сопоставлений (платформа Entity Framework)