Resolving naming convention conflict between entities in EF4 and our database standards?

前端 未结 3 915
我在风中等你
我在风中等你 2021-01-14 13:31

I\'m investigating replacing or supplementing our home grown ORM system with the Entity Framework 4, and I\'m noticing that the latter may end up causing a conflict between

3条回答
  •  猫巷女王i
    2021-01-14 14:05

    You can do it . You need to implement a custom model builder to map your entities with relevant tables and relevant columns. You can override OnModelCreating function to build a custome model by adding this function to your context class.

    protected override void OnModelCreating(DbModelBuilder modelBuilder)
            {
         modelBuilder.Entity().Map(c => c.ToTable("TableName"));//to map entity with table
         modelBuilder.Entity().Property(s => s.Property).HasColumnName("ColomnName");//to map properties with colomns
    }
    

提交回复
热议问题