Я получил ошибку, когда я запускаю миграции в рамках сущности основных
Введение ограничения внешнего ключа 'FK_PMS_UserRoles_PMS_Users_UserId' в таблице 'PMS_UserRoles' может привести к циклам или нескольким каскадным путям. Укажите при удалении без действия или при обновлении без действия или измените другие ограничения внешнего ключа.
Не удалось создать ограничение или индекс. Смотрите предыдущие ошибки.
Что я уже пробовал:
public class PMS_Company : IBaseEntity { public PMS_Company() { Users = new HashSet<PMS_User>(); Roles = new HashSet<PMS_Role>(); } public int Id { get; set; } public string CompanyName { get; set; } public string RegistrationNo { get; set; } public string OwnerName { get; set; } public string Logo { get; set; } public string Address { get; set; } public string PhoneNumber { get; set; } public bool IsActive { get; set; } public int CreatedBy { get; set; } public DateTime CreatedOn { get; set; } public int? EditedBy { get; set; } public DateTime? EditedOn { get; set; } public IReadOnlyCollection<PMS_User> Users { get; set; } public IReadOnlyCollection<PMS_Role> Roles { get; set; } } public class PMS_User : IBaseEntity { public PMS_User() { UserRoles = new HashSet<PMS_UserRole>(); } public int Id { get ; set ; } public string FirstName { get; set; } public string LastName { get; set; } public string Email { get; set; } public string Paswword { get; set; } public string salt { get; set; } public DateTime ExpireDate { get; set; } public bool IsActive { get ; set ; } public int CreatedBy { get ; set ; } public DateTime CreatedOn { get ; set ; } public int? EditedBy { get ; set ; } public DateTime? EditedOn { get ; set ; } public int CompanyId { get; set; } public PMS_Company Company { get; set; } public IReadOnlyCollection<PMS_UserRole> UserRoles { get; set; } } public class PMS_UserRole { public int UserId { get; set; } public PMS_User User { get; set; } public int RoleId { get; set; } public PMS_Role Role { get; set; } } public class PMS_Role : IBaseEntity { public PMS_Role() { UserRoles = new HashSet<PMS_UserRole>(); } public int Id { get ; set; } public string RoleName { get; set; } public string RoleNameN { get; set; } public bool IsActive { get; set; } public int CreatedBy { get; set; } public DateTime CreatedOn { get; set; } public int? EditedBy { get; set; } public DateTime? EditedOn { get; set; } public int CompanyId { get; set; } public PMS_Company Company { get; set; } public IReadOnlyCollection<PMS_UserRole> UserRoles { get; set; } } public class UserRolesConfiguration : IEntityTypeConfiguration<PMS_UserRole> { public void Configure(EntityTypeBuilder<PMS_UserRole> builder) { builder.ToTable("PMS_UserRoles"); builder.HasKey(x => new { x.RoleId, x.UserId }); builder.HasOne(ur => ur.Role) .WithMany(x => x.UserRoles) .HasForeignKey(x => x.RoleId); builder.HasOne(ur => ur.User) .WithMany(x => x.UserRoles) .HasForeignKey(x => x.UserId); } }