我有兩個模型類:出勤和員工。我已經定義Employee類爲:實體框架Codefirst中的外鍵幫助
public class Employee
{
public int Id { get; set; }
public string Username { get; set; }
public string Password { get; set; }
}
然後,我已經定義了考勤類爲:
public class Attendance
{
public int Id { get; set; }
public Employee Employee { get; set; } //This is the foreign key
public DateTime LoginDate { get; set; }
public DateTime LogoutDate { get; set; }
}
當我試圖將數據插入Employee表中它工作正常,但是當我嘗試在考勤表內插入數據會顯示異常。我正在檢查員工並在考勤表中只插入一行員工。
這裏是例外的圖像:
什麼是內部異常(按照主要異常的說明)。另外你如何創建和保存考勤對象? (顯示示例)。 – Umair