One to Many association problem in LINQ to SQL
I have the following associated property in my Employee
class, where EmployeePhoneNumber
is related, as the attributes declare, in the DB.
[TableAttribute(Name = "dbo.EmoployeePhoneNumber")]
public class EmployeePhoneNumber
and
[TableAttribute(Name = "dbo.Employee")]
public class Employee
{
[ColumnAttribute(IsPrimaryKey = true, IsDbGenerated = true)]
public int ID { get; set; }
[Association(Name = "Employee_EmployeePhoneNumbers", ThisKey = "ID", OtherKey = "EmployeeID")]
public EntitySet<EmployeePhoneNumber> PhoneNumbers { get; set; }
}
When I try and access GetTable<Employee>()
, I get the error:
Invalid association mapping for member 'Interview.Web.Models.Employee.PhoneNumbers'. 'Interview.Web.Models.EmployeePhoneNumber' is not an entity.
I am very new to LINQ to SQL, being an EF man u开发者_如何学Csed to the model designer, and I have to code these models by hand.
ColumnAttribute with IsPrimaryKey=true missing in EmployeePhoneNumber
精彩评论