0

How do I setup NetTopologySuite in .net core 2.2?

I have this already in startup.cs

  services.AddDbContext<ApplicationDbContext>(options =>
            options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));

https://learn.microsoft.com/en-us/ef/core/modeling/spatial

In the docs above it suggests to do something like this... Do I need to put my connection string in the context class too??

Also this code does not work it doesnt recognise UseNetTopologySuite

optionsBuilder.UseSqlServer(
    @"Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=WideWorldImporters",
    x => x.UseNetTopologySuite());

I added the nuget package, and added some usings... resharper cant even find what it needs despite doing

Install-Package NetTopologySuite
raklos
  • 28,027
  • 60
  • 183
  • 301

1 Answers1

0

Old question but just to help some others, cause I run into a similar problem.

In my case it was the wrong UseNetTopologySuite installed from nugget.

It must be the package Microsoft.EntityFrameworkCore.SqlServer.NetTopologySuite for SQL Server

https://learn.microsoft.com/en-us/ef/core/modeling/spatial (Read Installing for other databases)