-
Notifications
You must be signed in to change notification settings - Fork 60
Delete options set to None throws exception #257
Comments
You are right, tool works as you described, so when you set Default, db context does not add OnDelete() part, but EF core obviously generates CASCADE delete by default. Here is what I generated by context.Database.GenerateCreateScript() method called on the simple example with 2 simple tables. Delete option is set to Default: CREATE TABLE [dbo].[Details] ( CREATE INDEX [IX_Details_MasterId] ON [dbo].[Details] ([MasterId]); Now, everything is OK when I start new project with new tool version and EF 5, but in the case we have the old project with EF core 2.1. packages and new tool version and I try to set None action on relationship, since I don't want cascade, I get the error that DeleteBehaviorEnum does not contain NoAction value which is true since that value is introduced in EF core 3. So, tool allows me to chose None, but then tries to set this enum value which does not exist in EF core 2.1. I have chosen target framework 2.1 in the tool. |
Thanks. I've changed the T4 to generate DeleteBehavior.Restrict rather than DeleteBehavior.NoAction for EFCore < 3. The change will be published in v3.0.3 |
Hi Michael, me again. :)
What our team noticed recently is that when we moved to v3 of the tool, we saw different behavior when sql script is generated. If Default mode is set on the relationship itself, tool now generates CASCADE delete. I think that before NO ACTION was default (but maybe I am wrong, since when setting the Default, I see no explicit delete mode set in db context, which means it is up to EF core, not related to the tool probably).
Now, if I change the option to None, I end with the following error in compile time:
'DeleteBehavior' does not contain a definition for 'NoAction'
Can you please confirm the statement about the delete behaviour and check why we can not set None as action.
Thanks.
The text was updated successfully, but these errors were encountered: