【问题标题】:Building Project that uses EntityFramework fails with a lot of errors使用 EntityFramework 构建项目失败并出现很多错误
【发布时间】:2017-02-10 12:22:03
【问题描述】:

我在 Visual Studio C# 项目中使用 EntityFramework 作为我的数据访问层。我添加了一个新的实体模型并立即构建,而无需添加或做任何事情来测试其功能。不幸的是,构建失败并出现许多错误,例如:

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?)

代码编辑器本身看起来好像缺少某些东西,即使一切都到位

图片显示了我在项目中的编辑器和参考资料

P.S:项目类型为类库

【问题讨论】:

  • 该项目的“目标框架”是什么?您是否尝试右键单击解决方案 -> 清理,然后右键单击 -> 全部重建?

标签: c# entity-framework visual-studio ado.net entity-framework-6


【解决方案1】:

显然,这都是我的错。我在数据库中有一个名为“Systems”的表,当Entity Framework 将复数转换为单数时,它变成了“System”类,这给编译器造成了混乱和歧义。因此,编译器无法正确解析类型。

【讨论】:

  • 是的,我自己也有过这个。您必须小心使用实体名称,并尽量避免使用任何系统命名空间类名称,否则会变得非常混乱。
猜你喜欢
  • 2020-05-09
  • 1970-01-01
  • 1970-01-01
  • 2014-04-08
  • 1970-01-01
  • 2021-11-27
  • 2022-11-10
  • 2014-06-08
  • 2022-12-25
相关资源
最近更新 更多