How to configure Context to put table name in plural in en-BR?

Asked

Viewed 469 times

1

I am in an ASP.net MVC 5 application, configuring a class DbContext.

When the EF generates the database, the tables referring to the application objects are getting the names in the plural in English. For example:

public System.Data.Entity.DbSet<Teste.Models.Pastel> Pastel { get; set; }     

In the bank, the tables look like this:

dbo.pastels

There is a way to set the application’s plurarization to en-BR?

  • 1

    A solution for the name of the seats is to note the Class with [Table("NomeTabela")]

1 answer

3

To remove the plural overwrite the Onmodelcreating method:

protected overrride void OnModelCreating(ModelBuilder modelBuilder)
{ 
    modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
}

To set the table name do:

modelBuilder.Entity<NomeClasse>().ToTable("NomeTabelaClasse");  

Or

[Table("NomeTabela")]
public class NomeTabela
  • in this case I have to write all the table names manually. There is a way to set the plurarization to en-BR?

  • 1

    yes you will have to manually rsrsrsr, I do not know a way to set the language for the Entity to do pluralizing...

Browser other questions tagged

You are not signed in. Login or sign up in order to post.