Configuring cascade delete with EF7

asp.net-core entity-framework-core

Question

I'm trying to configure a cascade delete using EF7 in a ASP.NET vNext application but I cannot find how to do it.

I'm overriding OnModelCreating and I have this code:

  modelBuilder.Entity<Category>()
              .OneToMany<Category>( e => e.SubCategories )
              .ForeignKey( e => e.ParentCategoryId );

The generated migration looks like this:

    migrationBuilder.AddForeignKey("Category", "FK_Category_Category_ParentCategoryId", new[] { "ParentCategoryId" }, "Category", new[] { "Id" }, cascadeDelete: false);

Anyone know in what namespace the extensions to configure the cascade delete are defined?

Thanks!

Popular Answer

Promoting comment from lukew to an answer...

This is not yet implemented, work is being tracked here github.com/aspnet/EntityFramework/issues/333



Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why