This issue can be replicated easily, but I do not know the correct way to resolve it.
Classes:
public class Employee : IEntity<Guid>
{
public Guid Id { get; set; }
public Guid ApplicationUserId { get; set; }
public ApplicationUser ApplicationUser { get; set; }
public Guid CompanyId { get; set; }
public Company Company { get; set; }
}
public class Company : IEntity<Guid>
{
public Guid Id { get; set; }
public string Name { get; set; }
public IList<Employee> Employees { get; set; }
}
I'm using built-in identity ApplicationUser
class for user table.
I'm not getting any kind of error when generating migration but whenever I'm trying to update the database, I get an error:
Introducing FOREIGN KEY constraint on table 'Employee' may cause cycles or multiple cascade paths. Specify ON DELETE NO ACTION or ON UPDATE NO ACTION, or modify other FOREIGN KEY constraints.
What is the appropriate way to resolve this issue using Fluent API?
Project type: ASP.NET Core MVC