使用EntityFramework的构建项目失败,出现很多错误 [英] Building Project that uses EntityFramework fails with a lot of errors
问题描述
我正在使用EntityFramework作为Visual Studio C#项目中的数据访问层。我添加了一个新的实体模型,并立即构建,而没有添加或做任何测试其功能的事情。不幸的是,构建失败并出现许多错误,例如:
I am using EntityFramework as my Data Access Layer in a Visual Studio C# project. I have added a new entity model and built right away without adding or doing anything to test its functionality. Unfortunately, the build failed with many errors like:
CS0426 The type name 'Data' does not exist in the type 'System'
CS0138 A 'using namespace' directive can only be applied to namespaces; 'System' is a type not a namespace. Consider a 'using static' directive instead
CS0246 The type or namespace name 'Nullable<>' could not be found (are you missing a using directive or an assembly reference?)
即使每件事都准备就绪,代码编辑器本身也似乎缺少了某些东西
The code editor itself appears as though it is missing something even though every thing is in place
图片显示了两者我在项目中拥有的编辑器和引用
The pictures show both the editor and the references that I have in my project
PS:项目类型为类库
P.S: The project type is Class Library
推荐答案
显然,这都是我的错误。我在数据库中有一个名为 Systems的表,当 Entity Framework
将复数形式转换为单数形式时,它变成了 System类,这给编译器造成了混乱和歧义。因此,编译器无法正确解析类型。
Apparently, it is all my mistake. I had a table in the Database called "Systems" and when Entity Framework
turned the plural into singular it became "System" class which caused confusion and ambiguity to the compiler. Consequently, the compiler could not correctly resolve the type.
这篇关于使用EntityFramework的构建项目失败,出现很多错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!