Updated on Kisan Patel
Here is the full error:
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); }