我正在使用EF代码第一种方法,并希望添加一个链接(map)表.我正在处理以下示例并获得以下错误:
System.Data.Entity.Edm.EdmEntityType: : EntityType 'EmployeeDepartmentLink' has no key defined. Define the key for this EntityType.
Run Code Online (Sandbox Code Playgroud)
问题是我不想在这张桌子上放一把钥匙它只是将两张桌子映射在一起:
public class Employee
{
[Key()]
public int EmployeeID;
public string Name;
}
public class Department
{
[Key()]
public int DepartmentID;
public string Name;
}
public class EmployeeDepartmentLink
{
public int EmployeeID;
public int DepartmentID;
}
Run Code Online (Sandbox Code Playgroud)
我已经尝试了各种各样的事情,比如添加"[Key()]"属性,但是它没有意义使用它,我将它添加到哪个字段?我想知道是否支持这种表模型?