我正在尝试使用EF Core 2.2的新功能 . 它基于以下文章 . "Announcing Entity Framework Core 2.2" https://blogs.msdn.microsoft.com/dotnet/2018/12/04/announcing-entity-framework-core-2-2/
我安装了以下Nuget包 .
我在模型中添加了以下内容 .
using NetTopologySuite.Geometries;
//New as of EF.Core 2.2
//[Required]
//[NotMapped]
public Point Location { get; set; }
在我的应用程序启动期间,我在以下行的数据库上下文中收到以下错误:Database.EnsureCreated();
System.InvalidOperationException HResult = 0x80131509 Message =属性'Point.Boundary'是接口类型('IGeometry') . 如果是导航属性,则通过将此属性转换为映射实体类型来手动配置此属性的关系,否则使用NotMappedAttribute或“OnModelCreating”中的“EntityTypeBuilder.Ignore”忽略该属性 . 来源= Microsoft.EntityFrameworkCore
1 回答
你需要拨打
UseNetTopologySuite()
. 这里的例子:我遇到了这个问题,因为我的
OnConfiguring
周围有一个if (!optionsBuilder.IsConfigured)
. 我必须删除它才能让add-migrations
工作 .