The type 'SpatialDbContext' does not inherit from DbContext. The DbMigrationsConfiguration.ContextType property must be set to a type that inherits from DbContext.
This is the error showing when I am enabling migrations. What can I try to fix this?
SpatialDbContext is inherited from DbContext,but it still showing above error
What I have tried:
using SpatialSample.Entities;
using NetTopologySuite;
using NetTopologySuite.Geometries;
using System;
using Microsoft.EntityFrameworkCore;
namespace SpatialSample
{
public class SpatialDbContext : DbContext
{
public DbSet<TouristAttraction> TouristAttractions { get; set; }
public SpatialDbContext(DbContextOptions options) : base(options) { }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
var geometryFactory = NtsGeometryServices.Instance.CreateGeometryFactory(srid: 4326);
modelBuilder.Entity<TouristAttraction>()
.HasData(
new TouristAttraction
{
Id = 1,
Name1 = "Taj Mahal",
Location = (GeoAPI.Geometries.IPoint)geometryFactory.CreatePoint(new Coordinate(27.175015, 78.042155))
},
new TouristAttraction
{
Id = 2,
Name1 = "The Golden Temple of Amritsar",
Location = (GeoAPI.Geometries.IPoint)geometryFactory.CreatePoint(new Coordinate(31.619980, 74.876485))
},
new TouristAttraction
{
Id = 3,
Name1 = "The Red Fort, New Delhi",
Location = (GeoAPI.Geometries.IPoint)geometryFactory.CreatePoint(new Coordinate(28.656159, 77.241020))
},
new TouristAttraction
{
Id = 4,
Name1 = "The Gateway of India, Mumbai",
Location = (GeoAPI.Geometries.IPoint)geometryFactory.CreatePoint(new Coordinate(18.921984, 72.834654))
},
new TouristAttraction
{
Id = 5,
Name1 = "Mysore Palace",
Location = (GeoAPI.Geometries.IPoint)geometryFactory.CreatePoint(new Coordinate(12.305025, 76.655753))
},
new TouristAttraction
{
Id = 6,
Name1 = "Qutb Minar",
Location = (GeoAPI.Geometries.IPoint)geometryFactory.CreatePoint(new Coordinate(28.524475, 77.185521))
}
);
}
}
}