I have an MVC project and using Entity Framework Code First and POCO objects for the database. For example:
public class ClassA
{
public int? Id {get; set;
I solved it by changing ClassA with a foreign key to ClassB, and setting the value of BId:
public class ClassA
{
public int? Id {get; set;}
public string Name { get; set;}
public int BId {get;set;} // foreign key to B
public virtual ClassB B {get; set;}
}
Why does this foreign key property does the job instead of the generated foreign ky of EF?