kamran_14
جمعه 29 تیر 1397, 16:16 عصر
سلام
چرا وقتی 2 تا از کلیدخارجیها اجباری میشوند برنامه هنگام اجرا خطا میده ولی وقتی یکیش اختیاری میشه دیگه خطا نمیده؟
خطا این است.
Public class tblMessage
{
public int ID { get; set; }
……………
……………
[System.ComponentModel.DataAnnotations.Schema.Inver seProperty("tblMessages")]
[System.ComponentModel.DataAnnotations.Schema.Forei gnKey("UserSend")]
public virtual tblUser tblUser { get; set; }
[System.ComponentModel.DataAnnotations.Schema.Inver seProperty("tblMessages2")]
[System.ComponentModel.DataAnnotations.Schema.Forei gnKey("UserGet")]
public virtual tblUser tblUser2 { get; set; }
}
Public class tblUser {
public int ID { get; set; }
……………
……………
[System.ComponentModel.DataAnnotations.Schema.Inver seProperty("tblUser")]
public virtual List<tblMessage> tblMessages { get; set; }
[System.ComponentModel.DataAnnotations.Schema.Inver seProperty("tblUser2")]
public virtual List<tblMessage> tblMessages2 { get; set; }
}
148579
چرا وقتی 2 تا از کلیدخارجیها اجباری میشوند برنامه هنگام اجرا خطا میده ولی وقتی یکیش اختیاری میشه دیگه خطا نمیده؟
خطا این است.
Public class tblMessage
{
public int ID { get; set; }
……………
……………
[System.ComponentModel.DataAnnotations.Schema.Inver seProperty("tblMessages")]
[System.ComponentModel.DataAnnotations.Schema.Forei gnKey("UserSend")]
public virtual tblUser tblUser { get; set; }
[System.ComponentModel.DataAnnotations.Schema.Inver seProperty("tblMessages2")]
[System.ComponentModel.DataAnnotations.Schema.Forei gnKey("UserGet")]
public virtual tblUser tblUser2 { get; set; }
}
Public class tblUser {
public int ID { get; set; }
……………
……………
[System.ComponentModel.DataAnnotations.Schema.Inver seProperty("tblUser")]
public virtual List<tblMessage> tblMessages { get; set; }
[System.ComponentModel.DataAnnotations.Schema.Inver seProperty("tblUser2")]
public virtual List<tblMessage> tblMessages2 { get; set; }
}
148579