pankaj kshatriya
pankaj kshatriya

Reputation: 233

ASP.NET Core 2.2 am getting an error on my OnModelCreating method after upgrading to Core 3.0

I am upgrading my .net core 2.2 project to release .net core 3.0 version. While upgrading project, I have also updated the below packages.

  1. Microsoft.EntityFrameworkCore.SqlServer with version 3.0.0

  2. Microsoft.EntityFrameworkCore.Tools with version 3.0.0

  3. Npgsql.EntityFrameworkCore.PostgreSQL with version 3.0.0.

But i am getting below error

Error CS1061 'IMutableEntityType' does not contain a definition for 'Relational' and no ccessible extension method 'Relational' accepting a first argument of type 'IMutableEntityType' could be found are you missing a using directive or an assembly reference?)

Please see the code and getting error on line number 2:

modelBuilder.Model.GetEntityTypes()
 .Select(e => e.Relational()).ToList()
 .ForEach(t => t.TableName = t.TableName.ToLower());

How do I fix it?

Upvotes: 0

Views: 780

Answers (1)

Kahbazi
Kahbazi

Reputation: 15005

This is a breaking change based on docs and you should use GetTableName and SetTableName instead

modelBuilder.Model.GetEntityTypes()
    .ToList()
    .ForEach(e => e.SetTableName(e.GetTableName().ToLower()));

Upvotes: 3

Related Questions