私はEntity Framework Codeを最初に使用しています。私のクラスは
[Serializable]
public class Emp
{
public int EmpId { get; set; }
public byte TitleId { get; set; }
[MaxLength(50)]
public string FirstName { get; set; }
[MaxLength(50)]
public string Surname { get; set; }
public byte Type { get; set; }
public List<PracticeEmp> PracticeEmps { get; set; }
}
[Serializable]
public class PracticeEmp
{
public int PracticeStaffId { get; set; }
public int PracticeId { get; set; }
public int EmpId { get; set; }
public DateTime? StartDate { get; set; }
public DateTime? EndDate { get; set; }
public Emp Emp { get; set; }
}
既に存在する譜表の PracticeEmps テーブルにデータを挿入しようとしているときに、次のコードを使用します
Db.Current.Emps.Attach(practiceEmp.Emp);
Db.Current.PracticeEmps.Add(practiceEmp);
このコード セグメントは、アタッチ メソッドでエラーを返します。
何か案は...