2010-02-04 80 views
13

在创建实体模型时,出现以下错误。实体模型问题:无法为一个特定表创建模型

Added the connection string to Web.Config. 
Successfully registered the assembly 'System.Data.Entity, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' in Web.Config. 
ERROR: Unable to generate model because of the following exception: 'Value does not fall within the expected range.'. 
Loading metadata from database took 00:00:02.1203632. 
Generating model took 00:00:00.8390920. 
Writing out the EDMX file took 00:00:00. 

所有表正在创建,但BC_States表没有被创建。我无法理解为什么。

回答

7

这个问题不可读,但我在Ado.Net Entity Data Model Not Updating Correctly找到类似的问题。

至于我(我有同样的问题),这个问题是因为在其中一个表上没有设置主键。

+0

这也是我的问题。只是改变了表格,我可以很好地导入表格。 – Ammar 2012-05-16 17:55:27

+0

同样的问题在我的情况。现在解决。 – Jamil 2017-10-24 07:11:43

19

我刚刚调查过类似的问题。事实证明,Entity Framework会在Visual Studio中的Error List窗口的Messages部分输出其他错误信息。

正如您所看到的,它比出现在Output窗口中的一般错误更有用。这对帮助我解决我的问题至关重要。

enter image description here

+4

感谢您发布此信息,它会花费我一些时间来查看“信息”,因为它应该放在'错误'恕我直言。 – 2012-01-11 18:26:39

+0

同意,我只看了很多头挠! – 2012-01-11 18:49:38