我想不通为什么我突然得到这些编译错误。让我们通过我采取的步骤:使用Razor视图引擎ADO.NET自我追踪实体生成器编译错误
2)在我的模型文件夹
1)我创建了一个新的ASP.NET MVC3项目(C#),我添加一个ADO.NET实体数据型号,将其连接到我的数据库,并命名它Database.edmx
3)我打开我的Database.edmx并选择添加代码生成项目。然后添加一个Selft-Tracking实体生成器并将其称为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文件夹中或硬盘驱动器上的外部位置也无关紧要。
有没有人有任何想法,为什么这是失败?谢谢。
的确,我的数据库中有一个表格Type ...没有想到这一点。谢谢! – Matthias 2011-05-12 18:53:10
我刚刚遇到了一个名为“EntityType”的表导致相同问题的问题。我只是将DataModel.Context.tt文件中的每个提及的“EntityType”都编辑为“System.Data.Metadata.Edm.EntityType”,而不是修复它。 – 2011-07-26 16:53:14