EntityFramework 4.1 Code First incorrectly names complex type column names

最后都变了- 提交于 2019-12-05 14:18:05

That is correct behavior. Default convention always prefixes properties mapped to complex type with type name. If you want to use different column names you must map them either through data annotations:

public class Address
{
    [Column("City")]
    public string City { get; set; }
    ...
}

or through fluent API:

modelBuilder.ComplexType<Address>().Property(a => a.City).HasColumnName("City");
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!