gpt4 book ai didi

entity-framework - 类型 'System.Data.Spatial.DbGeography' 必须是不可为 null 的值类型才能将其用作参数 'T'

转载 作者:行者123 更新时间:2023-12-04 02:52:59 24 4
gpt4 key购买 nike

我正在使用 EF 6,但我的一个模型出现了一个非常奇怪的错误:

字段配置是:

Property(x => x.IncidentLocationGps).HasColumnName("IncidentLocationGPS").IsOptional();

错误是:

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

预先感谢您的帮助

最佳答案

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

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

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

最近构建的 EF6 NuGet 包从项目中删除了对 System.Data.Entity.dll 的引用。

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

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

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

关于entity-framework - 类型 'System.Data.Spatial.DbGeography' 必须是不可为 null 的值类型才能将其用作参数 'T',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17202440/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com