【发布时间】:2011-05-12 18:05:57
【问题描述】:
我不明白为什么我突然得到这些编译错误。让我们来看看我采取的步骤:
1) 我使用 Razor 视图引擎创建了一个新的 MVC3 ASP.NET 项目 (C#)
2) 在我的 Models 文件夹中,我添加了一个 ADO.NET 实体数据模型,将其连接到我的数据库,并将其命名为 Database.edmx
3) 我打开我的 Database.edmx 并选择添加代码生成项。然后我添加一个 Selft-Tracking Entity Generator 并将其命名为 Model.tt
一切都是自动生成的。然而,当我点击构建时,我得到以下编译错误:
Error 1 Cannot implicitly convert type 'System.Type' to 'MyOwnProject.Models.Type'
Error 2 'MyOwnProject.Models.Type' does not contain a definition for 'IsValueType' and no extension method 'IsValueType' accepting a first argument of type 'MyOwnProject.Models.Type' could be found (are you missing a using directive or an assembly reference?)
Error 3 'MyOwnProject.Models.Type' does not contain a definition for 'IsGenericType' and no extension method 'IsGenericType' accepting a first argument of type 'MyOwnProject.Models.Type' could be found (are you missing a using directive or an assembly reference?)
Error 4 'MyOwnProject.Models.Type' does not contain a definition for 'GetGenericTypeDefinition' and no extension method 'GetGenericTypeDefinition' accepting a first argument of type 'MyOwnProject.Models.Type' could be found (are you missing a using directive or an assembly reference?)
Error 5 Cannot implicitly convert type 'System.Type' to 'MyOwnProject.Models.Type'
Error 6 'MyOwnProject.Models.Type' does not contain a definition for 'FullName' and no extension method 'FullName' accepting a first argument of type 'MyOwnProject.Models.Type' could be found (are you missing a using directive or an assembly reference?)
Error 7 'MyOwnProject.Models.Type' does not contain a definition for 'FullName' and no extension method 'FullName' accepting a first argument of type 'MyOwnProject.Models.Type' could be found (are you missing a using directive or an assembly reference?)
对我来说,这根本没有意义。我已经用这种方式创建了数据库的新项目十几次,现在,突然之间,我得到了这些编译错误。我命名数据库、edmx 或模型并没有什么区别。数据库是位于 App_Data 文件夹中还是位于我的硬盘驱动器上的外部位置也没有区别。
有人知道为什么会失败吗?谢谢。
【问题讨论】:
标签: c# entity-framework asp.net-mvc-3 ado.net