我正在尝试添加到数据库VipClient。
型号:
public class VipClient
{
public long Id { get; set; }
public virtual Client Client { get; set; }
public string Comment { get; set; }
public DateTime CreationTime { get; set; }
}
映射:
public class VipClientMap : IMappingEntity<VipClient>
{
public void Map(EntityTypeBuilder<VipClient> builder)
{
builder.ForNpgsqlToTable("vip_clients", "clients");
builder.HasKey(entity => entity.Id);
builder
.HasOne(entity => entity.Client)
.WithMany()
.HasForeignKey("vip_client_id");
builder
.Property(entity => entity.Comment)
.HasColumnName("vip_client_comment")
.IsRequired();
builder
.Property(entity => entity.CreationTime)
.HasColumnName("creation_time")
.IsRequired();
}
}
当我向数据库添加新的VipClient时 - 关系“vip_clients”的“列”ID“不存在”异常
我认为问题在于映射