Skip to content
This repository has been archived by the owner on Jan 16, 2024. It is now read-only.

EFCore 5: Compile Error when Using OnDelete Cascade #243

Closed
ab-tools opened this issue Nov 30, 2020 · 8 comments
Closed

EFCore 5: Compile Error when Using OnDelete Cascade #243

ab-tools opened this issue Nov 30, 2020 · 8 comments
Labels
bug Confirmed bug released Issue is resolved in a current release
Milestone

Comments

@ab-tools
Copy link

Hello Michael,

unfortunately, with your last update v3.0, probably due to fixing issue #240, it not even builds anymore.

Here another sample project:
EFDesignerCoreTest.zip

When using the OnDelete Cascade option you now get a compiler error:
modelBuilder.Entity<global::EFDesignerCoreTest.Entity1>().Navigation(e => e.EntityImplementation).OnDelete(DeleteBehavior.Cascade);

Best regards
Andreas

@msawczyn
Copy link
Owner

Thanks for pointing that out. The test case you show is a bit of an edge condition, and didn't have good coverage in the test model.

@msawczyn msawczyn added the bug Confirmed bug label Nov 30, 2020
@msawczyn msawczyn added this to the 3.0.1 milestone Nov 30, 2020
@ab-tools
Copy link
Author

ab-tools commented Nov 30, 2020

Thanks for the quick reply, Michael!

In the example above setting OnDelete to Cascade would even not be needed as I understand from here, because the relation is required and thus Cascade equals to Default anyway.
So I guess setting it explicitly to Cascade shouldn't have a lot of effect, does it?

But I just tried with a non-required relationship where the Cascade option is more useful, but it also doesn't like it in that case.

Thanks
Andreas

@msawczyn
Copy link
Owner

Since it was manually changed, the T4 picks that up and generates the code for the cascade command, albeit in the wrong place currently. There's no check to see if it's the same as the default in this case.

@ab-tools
Copy link
Author

ab-tools commented Dec 1, 2020

Not sure if that would be possible, but I think it would be a great feature if the designer what show somehow (e. g. by adding a (default) behind Cascade or None) what the default behavior is.

@msawczyn msawczyn added the pending release Issue is resolved in the current codebase, will be published with the next release label Dec 1, 2020
@msawczyn
Copy link
Owner

msawczyn commented Dec 1, 2020

Possible, yes, but lots of trouble. The default depends on the cardinalities (multiplicities) of the association, and changing the choices in a property editor isn't something done ad hoc. While it would be a nicety, when you consider development and testing effort, it's more trouble than it's worth.

@ab-tools
Copy link
Author

ab-tools commented Dec 1, 2020

I see, yeah, although it would be a nice feature (to keep the model as simple as possible by "informing" the user when he sets a property which is default this way anyway), but if that's a big hazzle to implement, it's probably not worth the effort indeed.

By the way, I tried your new build in the dist directory, but I guess that's just not finished in regards of this bug yet:
At least it does not generate any OnDeletes anymore for me at all which fixes the compiler error, but is probably not the best solution. ;-) Or I just missed them while looking through the generated code now...

@msawczyn msawczyn added released Issue is resolved in a current release and removed pending release Issue is resolved in the current codebase, will be published with the next release labels Dec 4, 2020
@msawczyn
Copy link
Owner

msawczyn commented Dec 4, 2020

Released in 3.0.1

@msawczyn msawczyn closed this as completed Dec 4, 2020
@ab-tools
Copy link
Author

ab-tools commented Dec 4, 2020

Thanks, Michael, tested and works well for me now!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Confirmed bug released Issue is resolved in a current release
Projects
None yet
Development

No branches or pull requests

2 participants