CTP5 Code First, Changing default Plural Table name to that of the Entity Name which is Singular.


  • Is there a way in CTP5 we would change the default generated table name from plural to the name of the entity itself which is singular. I am aware I could either decorate the class with the <Table(“NameHere”)> attribute or I could use something like this  modelBuilder.Entity(Of Asset).ToTable("Asset") in OnModelCreating. But since I am going to make this work with existing database tables which are singular, I was wondering if there was a way to globally tell EF to match the entity name to the table name for all the entities in my project.

    Wednesday, December 15, 2010 7:49 PM


  • The pluralizing of table names can be turned off by removing the convention that performs this service.  For example:


            protected override void OnModelCreating(ModelBuilder modelBuilder)





    The convention is in the System.Data.Entity.ModelConfiguration.Conventions.Edm.Db namespace.




    Thursday, December 16, 2010 3:01 AM