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

1

I'm in an ASP.NET MVC 5 application, setting up a DbContext class.

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

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

In the database, the tables look like this:

dbo.pastels

Is there a way to configure application pluralization for pt-BR?

    
asked by anonymous 15.07.2016 / 18:39

1 answer

3

To remove the plural override 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
    
15.07.2016 / 18:47