2011-11-22 14 views

risposta

22

Se si dispone di una sola entità che è associato a una tabella che non è pluralizeed allora si può rimuovere il PluralizingTableNameConvention e configurare manualmente il nome della tabella dell'entità.

public class MyContext : DbContext 
{ 
    protected override void OnModelCreating(DbModelBuilder modelBuilder) 
    { 
     base.OnModelCreating(modelBuilder); 

     modelBuilder.Conventions.Remove<PluralizingTableNameConvention>(); 

     modelBuilder.Entity<Item>().ToTable("Items"); 
    } 
} 

O se è l'otherway intorno

public class MyContext : DbContext 
{ 
    protected override void OnModelCreating(DbModelBuilder modelBuilder) 
    { 
     base.OnModelCreating(modelBuilder); 

     modelBuilder.Entity<Item>().ToTable("Item"); 
    } 
} 
+0

brillante, grazie. –

Problemi correlati