标签:.config prot err oid creat context override ati intent
EF中的映射: public class USERTBMapping:EntityTypeConfiguration<USER>
{
public USERTBMapping()
{
this.ToTable("USERTB");
}
}
2、在context中注册mapping
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Configurations.Add(new USERTBMapping());
throw new UnintentionalCodeFirstException();
}
三、直接指定
直接再context类中通过代码指定
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
//modelBuilder.Configurations.Add(new USERTBMapping());
//映射表名和列名
modelBuilder.Entity<USER>().ToTable("USERTB")
.Property(u => u.USERNM).HasColumnName("USERNAME");
throw new UnintentionalCodeFirstException();
}
标签:.config prot err oid creat context override ati intent
原文地址:http://blog.51cto.com/3544640/2153018