Entity Framework - CTP4 - Code First - How to turn off the automatic pluralization?

前端 未结 5 642
慢半拍i
慢半拍i 2021-01-01 00:20

My entity name is \"Contact\" and my table name is \"Contact\". However, the default pluralization support is making EF4 to look for a table named \"Contacts\". Anybody has

5条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-01 00:41

    Are you simply trying to target a particular table name?

    If so, this may be the answer you are looking for:

    public class FooDataContext : DbContext
    {
        public DbSet Contacts { get; set; }
    }
    
        protected override void OnModelCreating(System.Data.Entity.ModelConfiguration.ModelBuilder modelBuilder)
        {
            modelBuilder.Entity().MapSingleType().ToTable("Contact");
        }
    }
    

    Does this help or did I completely miss the point?

提交回复
热议问题