Efcore: Design: Scan target project for [DesignTimeServicesReference]

Created on 19 Oct 2018  路  4Comments  路  Source: dotnet/efcore

I have an existing DB with a Geography column. When running the Scaffold command, it still says it can't support:

Scaffold-DbContext "myconnectionstring" Microsoft.EntityFrameworkCore.SqlServer -o "Models\DB" -force
Could not find type mapping for column 'dbo.Venue.Location' with data type 'geography'. Skipping column.
Unable to scaffold the index 'inxVenueLocation'. The following columns could not be scaffolded: Location.

I have this package installed:

Microsoft.EntityFrameworkCore.SqlServer.NetTopologySuite

closed-fixed customer-reported type-bug

All 4 comments

Do you have multiple projects in your solution?

I suspect you're using a separate startup project from the one where the NTS extension package is installed.

We should probably scan for design-time services in the target project as well as the startup project.

As a workaround, you can add this code to your startup project:

using Microsoft.EntityFrameworkCore.Design;

[assembly: DesignTimeServicesReference(
    "Microsoft.EntityFrameworkCore.SqlServer.Design.Internal.SqlServerNetTopologySuiteDesignTimeServices, Microsoft.EntityFrameworkCore.SqlServer.NetTopologySuite",
    "Microsoft.EntityFrameworkCore.SqlServer")]

This work around worked. Thanks!

Was this page helpful?
0 / 5 - 0 ratings