Entity Framwork 6 编译出错的问题(VS2012)

在VS2012中使用EF6上来建立一个Entity Data Model后啥都不干,编译都会报错。

错误如下:

Value of type ‘System.Data.Objects.ObjectParameter‘ cannot be converted to ‘System.Data.Entity.Core.Objects.ObjectParameter‘.

Value of type ‘System.Data.Entity.Core.Objects.ObjectResult(Of DataLibrary.MyStoredProc_Result)‘ cannot be converted to ‘System.Data.Objects.ObjectResult(Of DataLibrary.MyStoredProc_Result)‘

Google一搜有很多,最符合的在这里:http://stackoverflow.com/questions/19661494/entity-framework-6-cannot-build-after-adding-stored-procedures-to-data-model

解决方法:

法一:回退到EF5

法二:将*.Context.tt文件中的

using System.Data.Objects;
using System.Data.Objects.DataClasses;

替换为

using System.Data.Entity.Core.Objects;
using System.Data.Entity.Core.Objects.DataClasses;

原因就是名称空间冲突了。

出处:http://www.bubuko.com/infodetail-1082755.html

原文地址:https://www.cnblogs.com/Kirsi/p/7809928.html