Building Project that uses EntityFramework fails w

2019-09-07 04:17发布

问题:

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

P.S: The project type is Class Library

回答1:

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.