【发布时间】:2018-09-05 17:41:31
【问题描述】:
我看过以下内容:
Entity framework code first map multiple complex types of the same type to a table
给出示例代码:
[Table("TXLifeRequest", Schema = "txlife")]
public partial class TXLifeRequest
{
public virtual OLI_LU_BOOLEAN PendingResponseOK { get; set; }
...
}
[Table("OLI_LU_BOOLEAN", Schema = "txlife")]
public partial class OLI_LU_BOOLEAN {
public string tc { get; set; }
public string Value { get; set; }
}
我想构造数据库,使OLI_LU_BOOLEAN 不在新表中,而是在TXLifeRequest 表中作为TXLifeRequest.PendingResponseOK_tc 和PendingResponseOK _Value 之类的两个新列。
现有上下文中没有流畅的代码。有没有办法通过 fluent 或 attrubutes 来做到这一点,以便类结构完整但表被合并?
更新:
我尝试了以下方法,但它为所有 OLI_LU_BOOLEAN 属性创建了一个新表 TXLifeRequest1。我如何将这些指定为同一张表的属性?
modelBuilder.ComplexType<OLI_LU_BOOLEAN>()
CreateTable("imsparamed.TXLifeRequest1",
c => new
{
Id = c.Int(nullable: false, identity: true),
PendingResponseOK_Value = c.String(),
PendingResponseOK_Id = c.Int(nullable: false)
})
【问题讨论】:
标签: entity-framework-6 ef-fluent-api