Estoy utilizando EntityFramework 4.1.Múltiples relaciones de uno a muchos con Entity Framework
tengo el siguiente modelo:
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; }
}
Cuando intento generar mi base de datos que tengo este error:
Unable to determine the principal end of an association between the types 'User' and 'User'. The principal end of this association must be explicitly configured using either the relationship fluent API or data annotations.
Pero también tengo esta clase:
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; }
}
Y funciona bien, tengo estas claves foráneas generadas:
Creator_Id
LastEditor_Id
¿Tengo algo que agregar en mi modelo de usuario para que funcione?
Tome un vistazo a esta pregunta y ver si se le lleva en la dirección correcta: http://stackoverflow.com/questions/6531671/what-does-principal-end-of-an-association-means-in-11-relationship-in-entity-fr – Cyric297