我有一个代表主表的Model,如下所示
public class Dad_Magazine_Master
{
[Key]
[Required]
[DisplayName("Type")]
public string MAGAZINE_TYPE { get; set; }
[Required]
[DisplayName("Name")]
public string MAGAZINE_NAME { get; set; }
[Required]
[DisplayName("Language")]
public string MAGAZINE_LANG { get; set; }
[Required]
[DisplayName("Duration")]
[Range(1, 100)]
public int MAGAZINE_DURATION { get; set; }
[Required]
[DisplayName("Region")]
public string MAGAZINE_REGION { get; set; }
[DisplayName("Expiry Date")]
public int MAGAZINE_EXPIRY_DATE { get; set; }
public int? CREATED_BY { get; set; }
public DateTime? CREATED_DATE { get; set; }
public int? MODIFIED_BY { get; set; }
public DateTime? MODIFIED_DATE { get; set; }
public virtual ICollection<Dad_Currency_Master> Currency { get; set; }
}
和子表模型如下..
public class Dad_Currency_Master
{
[Key] [Column(Order = 0)]
public string MEMBER_TYPE { get; set; }
[Key] [Column(Order = 1)]
public int D_CURRENCY_CODE { get; set; }
public int CURRENCY_VALUE { get; set; }
public int? CREATED_BY { get; set; }
public DateTime? CREATED_DATE { get; set; }
public int? MODIFIED_BY { get; set; }
public DateTime? MODIFIED_DATE { get; set; }
public virtual Dad_Magazine_Master Magazines { get; set; }
}
现在,我收到异常错误如下......
保存不公开其关系的外键属性的实体时发生错误。 GetEntityEntry方法将返回null,因为无法将单个实体标识为异常的来源。通过在实体类型中公开外键属性,可以更轻松地在保存时处理异常。有关详细信息,请参阅InnerException。
那么,出了什么问题?