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

.net .net-core entity-framework-core

Question

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?

1
0
10/22/2019 10:21:16 AM

Popular Answer

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()));
3
10/22/2019 10:34:55 AM


Related Questions





Related

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