boutique replica bags up ideas

the best replique rolex and prices here.

julia highlight 99j hair color 10a quality straight human hair lace front wigs 8 - 24 inches pre plucked hairline 13x4 inches lace front brazilian wig onlinefor sale

Entity Framework: Fix “FOREIGN KEY constraint may cause cycles or multiple cascade paths”

Updated on     Kisan Patel

Here is the full error:

Introducing FOREIGN KEY constraint ‘FK_dbo.aspnet_UsersInRoles_dbo.aspnet_Users_UserId’ on table ‘aspnet_UsersInRoles’ may cause cycles or multiple cascade paths. Specify ON DELETE NO ACTION or ON UPDATE NO ACTION, or modify other FOREIGN KEY constraints. Could not create constraint. See previous errors.

For fix this issue, we need to provides a convention to enable cascade delete for any required relationships.

protected override void OnModelCreating(DbModelBuilder modelBuilder )
{
   modelBuilder.Conventions.Remove<OneToManyCascadeDeleteConvention>();
}

OR

You can use WithCascadeOnnDelete(boolean) property to configures whether or not cascade delete is on for the relationship. It’s delete the Users if a aspnet_UsersInRoles is deleted (below code).

protected override void OnModelCreating( DbModelBuilder modelBuilder )
{
           modelBuilder.Entity<aspnet_UsersInRoles>().HasMany(i => i.Users)
                                               .WithRequired().WillCascadeOnDelete(false);
}

Entity Framework

Leave a Reply