i have a base Entity Class like this :
public abstract class BaseEntity
{
[System.ComponentModel.DataAnnotations.Key]
[System.ComponentModel.DataAnnotations.Required]
[Column("ID")]
[DatabaseGenerated(System.ComponentModel.DataAnnotations.Schema.DatabaseGeneratedOption.Identity)]
[System.ComponentModel.DataAnnotations.DataType("bigint")]
public long id { get; set; }
public virtual User createdBy { get; set; }
public virtual User updatedBy { get; set; }
public DateTime createdDate { get; set; }
public DateTime updatedDate { get; set; }
}
and a User Class for example like this :
public class User:BaseEntity
{
public string userName { get; set; }
}
but the EF give me an error when i want add record to the user table . the error is this :
Unable to determine the principal end of an association between the types 'MvcPractice.Models.User' and 'MvcPractice.Models.User'. The principal end of this association must be explicitly configured using either the relationship fluent API or data annotations.