I have the following models
public class Team
{
[Key,DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
public string Name { get; set; }
[ForeignKey("User")]
public int ManagerId { get; set; }
public virtual User User { get; set; }
}
Here is my User class:
public class User
{
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
[ForeignKey("Comapny")]
public int CompanyId { get; set; }
public virtual Company Company { get; set; }
}
Here is my Company class:
public class Company
{
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
public string Name { get; set; }
}
When I try to add a new migration I get the following error
The ForeignKeyAttribute on property 'CompanyId' on type 'ReportsEngine.Areas.Test.Models.User' is not valid. The navigation property 'Comapny' was not found on the dependent type 'ReportsEngine.Areas.Test.Models.User'. The Name value should be a valid navigation property name.
What am I doing wrong here?