Jacques Bourque
Jacques Bourque

Reputation: 1107

Configuring cascade delete with EF7

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!

Upvotes: 2

Views: 2211

Answers (1)

Rowan Miller
Rowan Miller

Reputation: 2090

Promoting comment from lukew to an answer...

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

Upvotes: 6

Related Questions