I am trying to use separate identity classes that inherit from ApplicationUser
, and create a relationship between them. Business and Customer where a Business can have many Customers. I get an error when adding relationships. What is the proper way to achieve adding identity between classes with relationships?
ApplicationUser.cs
public class ApplicationUser : IdentityUser
{
public virtual Business Business { get; set; }
public virtual Customer Customer { get; set; }
[Required]
[Display(Name = "First Name")]
public string FirstName { get; set; }
[Required]
[Display(Name = "Last Name")]
public string LastName { get; set; }
}
Business.cs
public class Business : ApplicationUser
{
public string BusinessUserId { get; set; }
[Required]
public string BusinessName { get; set; }
[Required]
[Display(Name = "Address")]
public string Address { get; set; }
public ICollection<Customer> Customers { get; set; }
....
}
Customer.cs
public class Customer : ApplicationUser
{
public string CustomerUserId { get; set; }
public override Business Business { get; set; }
}