-1

我被创造了两个班级。

[Table("SrvCenters")]
public class ManagerServiceCenter
{
    #region Public Properties

    /// <summary>
    /// Gets or sets the srv center id.
    /// </summary>
    [Key]
    public int SrvCenterId { get; set; }

    /// <summary>
    /// Gets or sets the branch id.
    /// </summary>
    public int BranchId { get; set; }

    /// <summary>
    /// Gets or sets the branch.
    /// </summary>
    public virtual Branch Branch { get; set; }

    /// <summary>
    /// Gets or sets the location id.
    /// </summary>
    public int LocationId { get; set; }

    /// <summary>
    /// Gets or sets the location.
    /// </summary>
    public virtual Location Location { get; set; }

    /// <summary>
    /// Gets or sets the description.
    /// </summary>
    public string Description { get; set; }

    /// <summary>
    /// Gets or sets the domain name.
    /// </summary>
    public string DomainName { get; set; }

    /// <summary>
    /// Gets or sets the active.
    /// </summary>
    public int Active { get; set; }

    #endregion
}

[Table("SrvCenters")]
public class AdminServiceCenter
{
    #region Public Properties

    /// <summary>
    /// Gets or sets the srv center id.
    /// </summary>
    [Key]
    public int SrvCenterId { get; set; }

    /// <summary>
    /// Gets or sets the active.
    /// </summary>
    public int Active { get; set; }

    /// <summary>
    /// Gets or sets the begin break.
    /// </summary>
    public TimeSpan BeginBreak { get; set; }

    /// <summary>
    /// Gets or sets the begin day.
    /// </summary>
    public TimeSpan BeginDay { get; set; }

    /// <summary>
    /// Gets or sets the branch id.
    /// </summary>
    public int BranchId { get; set; }

    /// <summary>
    /// Gets or sets the branch.
    /// </summary>
    public virtual Branch Branch { get; set; }

    /// <summary>
    /// Gets or sets a value indicating whether check time table.
    /// </summary>
    public int CheckTimeTable { get; set; }

    /// <summary>
    /// Gets or sets the create time.
    /// </summary>
    public DateTime? CreateTime { get; set; }

    /// <summary>
    /// Gets or sets the create user.
    /// </summary>
    public string CreateUser { get; set; }

    /// <summary>
    /// Gets or sets the cust priority id.
    /// </summary>
    public int CustPriorityId { get; set; }

    /// <summary>
    /// Gets or sets the customer bind id.
    /// </summary>
    public int CustomerBindId { get; set; }

    /// <summary>
    /// Gets or sets the delete count.
    /// </summary>
    public int DeleteCount { get; set; }

    /// <summary>
    /// Gets or sets the delete time.
    /// </summary>
    public int DeleteTime { get; set; }

    /// <summary>
    /// Gets or sets the description.
    /// </summary>
    public string Description { get; set; }

    /// <summary>
    /// Gets or sets the domain name.
    /// </summary>
    public string DomainName { get; set; }

    /// <summary>
    /// Gets or sets the end break.
    /// </summary>
    public TimeSpan EndBreak { get; set; }

    /// <summary>
    /// Gets or sets the end day.
    /// </summary>
    public TimeSpan EndDay { get; set; }

    /// <summary>
    /// Gets or sets a value indicating whether estimate wait time.
    /// </summary>
    public int EstimateWaitTime { get; set; }

    /// <summary>
    /// Gets or sets a value indicating whether have break.
    /// </summary>
    public int HaveBreak { get; set; }

    /// <summary>
    /// Gets or sets the hold order.
    /// </summary>
    public int HoldOrder { get; set; }

    /// <summary>
    /// Gets or sets the location id.
    /// </summary>
    public int LocationId { get; set; }

    /// <summary>
    /// Gets or sets the notif interval.
    /// </summary>
    public int NotifInterval { get; set; }

    /// <summary>
    /// Gets or sets a value indicating whether notification.
    /// </summary>
    public int Notification { get; set; }

    /// <summary>
    /// Gets or sets the priority direct id.
    /// </summary>
    public int PriorityDirectId { get; set; }

    /// <summary>
    /// Gets or sets the serv priority id.
    /// </summary>
    public int ServPriorityId { get; set; }

    /// <summary>
    /// Gets or sets the service bind id.
    /// </summary>
    public int ServiceBindId { get; set; }

    /// <summary>
    /// Gets or sets the srv center guid.
    /// </summary>
    public Guid SrvCenterGuid { get; set; }

    /// <summary>
    /// Gets or sets the sequence id.
    /// </summary>
    public int SequenceId { get; set; }

    /// <summary>
    /// Gets or sets the sequence.
    /// </summary>
    public virtual Sequence Sequence { get; set; }

    #endregion
}

尝试时我打电话给ManagerServiceCenter。我有异常

实体类型“AdminServiceCenter”和“ManagerServiceCenter”不能共享表“SrvCenters”,因为它们不在同一类型层次结构中,或者它们之间没有有效的一对一外键关系和匹配的主键。

好的

为什么这个类工作:)

/// <summary>
/// The workplace setting.
/// </summary>
[Table("SrvCenters")]
public class WorkplaceSetting
{
    /// <summary>
    /// Gets or sets the srv center id.
    /// </summary>
    [Key]
    public int SrvCenterId { get; set; }

    /// <summary>
    /// Gets or sets the net ident type id.
    /// </summary>
    public int NetIdentTypeId { get; set; }

    /// <summary>
    /// Gets or sets the help net ident type.
    /// </summary>
    [ForeignKey("NetIdentTypeId")]
    public virtual HelpNetIdentType HelpNetIdentType { get; set; }

    /// <summary>
    /// Gets or sets the w p_ auto start exec.
    /// </summary>
    public int WP_AutoStartExec { get; set; }

    /// <summary>
    /// Gets or sets the w p_ button mask.
    /// </summary>
    public int WP_ButtonMask { get; set; }

    /// <summary>
    /// Gets or sets the w p_ show info.
    /// </summary>
    public int WP_ShowInfo { get; set; }

    /// <summary>
    /// Gets or sets the w p_ show message.
    /// </summary>
    public int WP_ShowMessage { get; set; }

    /// <summary>
    /// Gets or sets the w p_ time between msg.
    /// </summary>
    public int WP_TimeBetweenMsg { get; set; }

    /// <summary>
    /// Gets or sets the w p_ time in idle.
    /// </summary>
    public int WP_TimeInIdle { get; set; }

    /// <summary>
    /// Gets or sets the w p_ time in resolve.
    /// </summary>
    public int WP_TimeInResolve { get; set; }

    /// <summary>
    /// Gets or sets the w p_ time show msg.
    /// </summary>
    public int WP_TimeShowMsg { get; set; }

    /// <summary>
    /// Gets or sets the description.
    /// </summary>
    public string Description { get; set; }

    /// <summary>
    /// Gets or sets the active.
    /// </summary>
    public int Active { get; set; }
}
4

1 回答 1

2

如果要在两个实体之间共享表,则必须使用TPH 继承表拆分。

于 2012-12-24T12:15:34.013 回答