Why was Relational() extention method removed in .net core 3?
The syntax has been changed a little bit in EF Core 3 according to this issue, here is the new version:
Pluralizer pluralizer = new Pluralizer();
foreach (IMutableEntityType entityType in modelBuilder.Model.GetEntityTypes())
{
string tableName = entityType.GetTableName();
entityType.SetTableName(pluralizer.Pluralize(tableName));
}
foreach (var entity in modelBuilder.Model.GetEntityTypes())
{
// Replace table names
//entity.Relational().TableName = entity.Relational().TableName.ToSnakeCase();
entity.SetTableName(entity.GetTableName().ToSnakeCase());
// Replace column names
foreach (var property in entity.GetProperties())
{
property.SetColumnName(property.Name.ToSnakeCase());
}
foreach (var key in entity.GetKeys())
{
key.SetName(key.GetName().ToSnakeCase());
}
foreach (var key in entity.GetForeignKeys())
{
key.PrincipalKey.SetName(key.PrincipalKey.GetName().ToSnakeCase());
}
foreach (var index in entity.GetIndexes())
{
index.SetName(index.GetName().ToSnakeCase());
}
}