I am using EntityFramework 4.1.
I have the following model:
public class User
{
[Key]
public int Id { get; set; }
public string Username { get; set; }
public string Password { get; set; }
public virtual User Creator { get; set; }
public virtual User LastEditor { get; set; }
}
When I try to create my database, I got this error:
It is not possible to determine the main end of the relationship between the User and User types. The primary goal of this association should be explicitly configured using either a free API or annotation data.
But I also have this class:
public class Course
{
[Key]
public int Id { get; set; }
public string Name { get; set; }
public virtual User Creator { get; set; }
public virtual User LastEditor { get; set; }
}
And it works fine, I have these foreign keys:
Creator_Id
LastEditor_Id
Do I have something to add to my User model to make it work?
source
share