Entity framework 从EF 5切换到EF 6 Alpha 3-现在DbGeography不工作
我的域名里有这个Entity framework 从EF 5切换到EF 6 Alpha 3-现在DbGeography不工作,entity-framework,spatial,Entity Framework,Spatial,我的域名里有这个 public DbGeography Location { get; set; } 这是我的地图 this.Property(t => t.Location); 现在在我的映射文件中,我在上面的一行中得到一个错误 Error 1 The type 'System.Data.Spatial.DbGeography' must be a non-nullable value type in order to use it as parameter 'T' in
public DbGeography Location { get; set; }
这是我的地图
this.Property(t => t.Location);
现在在我的映射文件中,我在上面的一行中得到一个错误
Error 1 The type 'System.Data.Spatial.DbGeography' must be a non-nullable value type in order to use it as parameter 'T' in the generic type or method 'System.Data.Entity.ModelConfiguration.Configuration.StructuralTypeConfiguration<TStructuralType>.Property<T>(System.Linq.Expressions.Expression<System.Func<TStructuralType,T>>)'
错误1类型“System.Data.Spatial.DbGeography”必须是不可为null的值类型,才能将其用作泛型类型或方法“System.Data.Entity.ModelConfiguration.Configuration.StructuralTypeConfiguration.Property(System.Linq.Expressions.Expression)”中的参数“T”
在EF5中从来没有出现过这个错误。这是我在深入阅读EF6文档后最终找到的解决方案 删除对System.Data.Entity.dll的程序集引用 安装EF6 NuGet包会将以下运行时程序集添加到项目中: EF6 NuGet包的最新版本将从项目中删除对System.Data.Entity.dll的引用 EF6不使用System.Data.Entity.dll中的任何代码,在项目中引用它可能会导致生成冲突。 这些冲突可以解决,但通常不应在同一应用程序中使用EF6和System.Data.Entity.dll
希望这可以帮助其他面临同样问题的人。删除对System.Data.Entity的引用在使用EF不可知POCO对象时不是一个解决方案。