1

I have a table with a many to many relation table here is config

HasMany(pb => pb.DeletedProducts)
    .WithMany()
    .Map(m =>
    {
        m.ToTable("ProductBatchDeleted");
        m.MapLeftKey("BatchId");
        m.MapRightKey("ProductId");
    });

There is no cascade delete option available for this as far as i can see.

Here is the delete code

await _context.DbSet<ProductBatch>()
                .DeleteAsync();

It fails with a constraint error because the table ProductBatchDeleted has a constraint to it. Can I fix so that the Extend library understands that it has todo a delete on the ProductBatchDeleted table first?

Anders
  • 17,306
  • 10
  • 76
  • 144
  • Take a look at this, see if fits in your situation. http://stackoverflow.com/questions/23398315/incomplete-ef-code-first-cascade-delete-on-many-to-many-relationship. Also, provide the class structure of `Batch` and `Products` – Fabio Nov 26 '15 at 13:29

0 Answers0