为什么VS 2015需要引用System.Data.Entity但VS 2013不需要? [英] Why does VS 2015 need a reference to System.Data.Entity but VS 2013 does not?
问题描述
我已经安装了VS 2015(虽然我之前安装了RC,但不是RC)。我打开了一个现有的解决方案,该解决方案在VS 2013中运行良好,并出现以下错误。
I've installed VS 2015 (not the RC though I had that installed prior). I opened an existing solution that was working fine in VS 2013 and got the following error.
BC30652组装'System.Data所需的引用。实体,
版本= 4.0.0.0,区域性=中性,PublicKeyToken = b77a5c561934e089'
,其中包含类型'EntityObject'。将一个添加到您的项目中。
BC30652 Reference required to assembly 'System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' containing the type 'EntityObject'. Add one to your project.
我按照VS的建议在项目中添加了对System.Data.Entity的引用,它可以正常工作。但是,我想知道为什么会这样。
I added a reference to System.Data.Entity in the project as VS suggested and it worked. However, I'm wondering why this happened.
如果删除System.Data.Entity引用,则VS 2013仍然有效,但VS 2015会引发错误。该项目确实有对System.Data的引用。
If I remove System.Data.Entity reference, VS 2013 still works but VS 2015 throws errors. The project does have a reference to System.Data.
有关解决方案的说明:
- 最初在VS 2013中开发
- .NET 4.0
- 还引用了System.Data
- 有2个项目,一个主要项目(导致错误)和DAL
- DAL具有实体数据模型(.edmx)
- Originally developed in VS 2013
- .NET 4.0
- Also has reference to System.Data
- Has 2 projects, a main (which causes the error) and a DAL
- The DAL has an Entity Data Model (.edmx)
推荐答案
我得到了Visual Basic语言团队的确认,这很可能是由于Visual Studio 2015中的编译器发生了更改:
I got confirmation from the Visual Basic language team that this is very likely due to a change in their compiler in Visual Studio 2015:
...实际上,我们确实在努力使事情变得宽松。但总结是,编译器可能需要更多引用才能确保正确性。如果可以,请添加它们。我相信如果您调用灯泡,可以快速解决此问题。
... we actually did work to try to make things more permissive. But the summary is that the compiler may require more references for correctness. Add them if you can. I believe there is a quick fix for it if you invoke the light bulb.
这篇关于为什么VS 2015需要引用System.Data.Entity但VS 2013不需要?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!