Sql server AdventureWorks可以';t创建ado.net实体数据模型

Sql server AdventureWorks可以';t创建ado.net实体数据模型,sql-server,visual-studio-2010,ado.net,Sql Server,Visual Studio 2010,Ado.net,我正在尝试使用microsoft的示例数据库AdventureWorks2008R2。。。尝试创建ADO.NET实体数据模型时,出现以下错误: Unable to generate the model because of the following exception: 'The table 'C:\USERS\XXXX\DOCUMENTS\VISUAL STUDIO 2010\PROJECTS\ANOTHERWORKS\ANOTHERWORKS\APP_DATA\ADVENTUREWORKS

我正在尝试使用microsoft的示例数据库AdventureWorks2008R2。。。尝试创建ADO.NET实体数据模型时,出现以下错误:

Unable to generate the model because of the following exception: 'The table 'C:\USERS\XXXX\DOCUMENTS\VISUAL STUDIO 2010\PROJECTS\ANOTHERWORKS\ANOTHERWORKS\APP_DATA\ADVENTUREWORKS2008R2_DATA.MDF.Production.Document' was referenced by a relationship, but was not found.'.
Loading metadata from the database took 00:00:06.2308687.
Generating the model took 00:00:04.5808698.
Added the connection string to the Web.Config file.
Successfully registered the assembly 'System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' in the Web.Config file.
Writing the .edmx file took 00:00:00.0015898.
有人遇到并修复了这个问题吗?或者知道在什么地方我可以下载这个数据库的工作版本(其他:我从哪里得到它)

或者有人可以指向我可以下载并与实体框架一起使用的示例数据库。

EDIT

新的EF设计器(Beta 1可用)不会尝试创建与不存在的表的关系,因此您将得到一个模型,其中无效的实体类型/集合和关系将被注释掉,而不是错误和空模型

**

我在AdventureWorks for Sql Server 2012中查看了它,但我认为它与您在2008年R2中使用的内容相同/ 这里的问题是Production.Document表有一个HierarchyId类型的键,而EF当前不支持HierarchyId类型。EF在创建模型时忽略其不了解的类型的列,但是如果它不了解键列,则将从模型中排除整个实体。对于排除的实体,当您使用Xml/文本编辑器打开模型时,应该能够在模型中找到注释掉的实体。在这种特殊情况下,我们将看到:

<EntityContainer Name="AdventureWorksModelStoreContainer" />
    <!--Errors Found During Generation:
  warning 6005: The data type 'hierarchyid' is currently not supported for the target .NET Framework version; the column 'DocumentNode' in table 'AdventureWorks.Production.Document' was excluded.
  warning 6031: The column 'DocumentNode' on the table/view 'AdventureWorks.Production.Document' was excluded, and is a key column.  The table/view has been excluded.  Please fix the entity in the schema file, and uncomment.

  <EntityType Name="Document">
    <Property Name="DocumentLevel" Type="smallint" StoreGeneratedPattern="Computed" />
    <Property Name="Title" Type="nvarchar" Nullable="false" MaxLength="50" />
    <Property Name="Owner" Type="int" Nullable="false" />
    <Property Name="FolderFlag" Type="bit" Nullable="false" />
    <Property Name="FileName" Type="nvarchar" Nullable="false" MaxLength="400" />
    <Property Name="FileExtension" Type="nvarchar" Nullable="false" MaxLength="8" />
    <Property Name="Revision" Type="nchar" Nullable="false" MaxLength="5" />
    <Property Name="ChangeNumber" Type="int" Nullable="false" />
    <Property Name="Status" Type="tinyint" Nullable="false" />
    <Property Name="DocumentSummary" Type="nvarchar(max)" />
    <Property Name="Document" Type="varbinary(max)" />
    <Property Name="rowguid" Type="uniqueidentifier" Nullable="false" />
    <Property Name="ModifiedDate" Type="datetime" Nullable="false" />
  </EntityType>-->
  </Schema>

注意这个警告:
警告6031:已排除表/视图“AdventureWorks.Production.Document”上的“DocumentNode”列,该列是一个键列。已排除该表/视图。请修复架构文件中的实体,并取消注释

现在在AdventureWorks数据库中,Production.ProductDocument表引用了Production.Document表。由于没有为Production.Document表创建实体,EF无法从Production.ProductDocument实体创建引用,因此“Production.Document”由关系引用,但找不到。错误

因为Production.Document表不能真正按原样使用“根据EF,最简单的解决方法是在从实体生成模型时排除此实体-检查除生产之外的所有表。在向导中创建文档,您就可以开始了。EF将忽略对该实体的所有引用,因为您已将其排除,因此不会出现错误


是否尝试使用SQL Express和基于文件的连接字符串来执行此操作?