.Net Core Delete Web API

I have a delete web api code written in .Net Core 3.0, code is working fine however there are foreign key constraints on a table where delete operation needs to be performed. Error is thrown as delete cannot be performed on foreign key columns. Please do let me know how to perform delete operation on the table.

Hi @Rohith_B.S

You need configure Cascade Delete on OnModelCreating in the your DbContext class it done with steps like the below snippet code.

 protected override void OnModelCreating(ModelBuilder modelBuilder)
        .HasOne(b => b.Author)
        .WithMany(a => a.Books)
.NET Foundation Website | Blog | Projects | Code of Conduct