Entity Framework Core - EF Core 2.2 - 'Point.Boundary' is of an interface type ('IGeometry')

前端 未结 2 1825
深忆病人
深忆病人 2021-01-05 06:16

I am trying the new functionality with EF Core 2.2. It is based on the following article. \"Announcing Entity Framework Core 2.2\" https://blogs.msdn.microsoft.com/dotnet/20

2条回答
  •  再見小時候
    2021-01-05 07:09

    You need to call UseNetTopologySuite(). Example here:

    public class ApplicationDbContext : IdentityDbContext
    {
        public ApplicationDbContext(DbContextOptions options)
            : base(options)
        {
    
        }
    
        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            IConfigurationRoot configuration = new ConfigurationBuilder()
               .SetBasePath(Directory.GetCurrentDirectory())
               .AddJsonFile("appsettings.json")
               .Build();
            var connectionString = configuration.GetConnectionString("DefaultConnection");
            optionsBuilder.UseSqlServer(connectionString, opts => opts.UseNetTopologySuite());
        }
        public DbSet Tests { get; set; }
    }
    
    
    public class Test
    {
        public int Id { get; set; }
        public Point Location { get; set; }
    }
    

    I ran into this problem because I had a if (!optionsBuilder.IsConfigured) around everything in my OnConfiguring. I had to remove this in order to get add-migrations to work.

提交回复
热议问题