Click here to Skip to main content
15,887,485 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Is there an option to set OnUpdate to Cascade of ForeignKey using Fluent API? There is only for OnDelete behavior.

What I have tried:

modelBuilder.Entity<Entiteti.NabavkeDetails>()
       .HasOne<Entiteti.Nabavke>()
       .WithMany()
       .OnDelete(DeleteBehavior.Cascade);
Posted
Updated 11-Feb-20 9:08am

1 solution

Currently, EF doesn't allow you to modify the primary key of an entity, so cascading updates don't make much sense. You will have to manually edit your migration to enable them, as described in this SO post[^].

There's a suggestion that this could change in a future version of EF Core:
It's not possible from the Fluent API today.

...

When mutable keys are enabled (issue #4073[^]) there will likely be Fluent API introduced to let you configure the ON UPDATE behavior.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900