2

我的域中有这个

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

EF 5 中从未出现过此错误。

4

1 回答 1

3

这是我在深入研究 EF6 文档后最终找到的解决方案。

删除对 System.Data.Entity.dll 的程序集引用

安装 EF6 NuGet 包会将以下运行时程序集添加到您的项目中:

EF6 NuGet 包的最新版本从项目中删除了对 System.Data.Entity.dll 的引用。

EF6 不使用 System.Data.Entity.dll 中的任何代码,并且在您的项目中引用它可能会导致生成冲突。

这些冲突可以解决,但通常您不应在同一应用程序中使用 EF6 和 System.Data.Entity.dll。

希望这可以帮助面临同样问题的其他人。

于 2013-06-22T09:36:25.553 回答