Base solution for your next web application
Open Closed

Disable cascading delete with Fluent API #9858


User avatar
0
andry3ag created

Hi Team,

We have recently downloaded the ASP.Net Core 3x with Anguylar 9.x (version 8.6). I want to create a table B which has 2 foreign keys to same ID(primary key) attribute on table A. Both foreign keyscannot be null so when I try to run the update database command I get error about "multiple cascade paths". I have looked and figured out that I need to disable cascading delete with Fluent API for both tables. I have found some examples for entity framework core but I never was able to use any of examples. Can you please share the code for disabling cascade delete for Table A for example?

Thanks


1 Answer(s)
  • User Avatar
    0
    musa.demir created

    Hi @andry3ag Most of the the time, multiple cascade paths error happens because of the circular dependencies of the entities. To detect the problem on your situtation we should able to see your entities and their relationship configurations. Can you please check that https://www.codeproject.com/Questions/5165632/I-got-an-error-whenever-I-run-migration-in-entity. It is an example that may help you.

    If you can not solve your problem with that, can you please share your entities and their relationship configurations(mostly located in dbcontext's OnModelCreating(ModelBuilder modelBuilder) method). If you don't want to share it publicly, you can send them to [email protected] with that support question url and inform us here.