PropertyBuilder Does Not Contain A Definition For HasColumnType

c# entity-framework-core fluent-entity-framework


I just built up a bunch of POCO classes and a DbContext class utilizing EntityFramework Core and the Scaffold-DbContext NuGet Package Manager Console command.

It generated a bunch of code and most of it is fine, except there are several calls to HasColumnType and HasName methods that are not found by the compiler. Unfortunately, VS2017 isn't helping me locate them either. I installed EntityFramework Core via the NuGet Package Manager and I figured all dependencies would've been correctly installed, but this does not appear to be the case. I've tried googling the namespace for HasColumnType but have been unable to find it.

Could someone please tell me what namespace or NuGet package I'm missing?

11/11/2017 12:20:07 AM

Accepted Answer

These extensions are in the Microsoft.EntityFrameworkCore.Relational package as they are useful for modeling relational databases.

11/11/2017 12:37:10 AM

Popular Answer

I also had the same question. As per this Microsoft docs link you would need to add a specific database provider nuget package, such as Microsoft.EntityFrameworkCore.SqlServer.

EF Core providers for relational databases are build on the common Microsoft.EntityFrameworkCore.Relational library, which provides APIs for configuring table and column mappings, foreign key constraints, etc. Providers are usually distributed as NuGet packages.

So no need to add both packages, adding the more specific one Microsoft.EntityFrameworkCore.SqlServer worked for me.

Related Questions


Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow