Reputation: 1541
Is there anyway to cascade delete false in the entity framework config settings. For now I have done using fluent API but there are multiple place where cascade delete need to be set false, so is there any single point where I can set for all classes, as I don't have any need of it.
Thanks.
Upvotes: 0
Views: 59
Reputation: 536
public partial class MyContext : DbContext
{
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Conventions.Remove<OneToManyCascadeDeleteConvention>();
}
}
Upvotes: 2
Reputation: 3082
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
//Set cascade options here also
}
Upvotes: 0