You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Scaffolding the DbContext/models with a SQL table that has a trigger does not generate HasTrigger() per a breaking change in EF7. As a result, a DbUpdateException occurs when saving changes that would cause the SQL trigger to fire.
Expected behavior HasTrigger() should be generated when needed and changes should save without throwing an exception.
To Reproduce
Run scaffolding on a SQL table that has a trigger.
Observe the DbContext generated does not include HasTrigger().
Run code that saves changes to the table with a trigger.
An exception is thrown:
Microsoft.EntityFrameworkCore.DbUpdateException: 'Could not save changes because the target table has database triggers. Please configure your entity type accordingly, see https://aka.ms/efcore-docs-sqlserver-save-changes-and-triggers for more information.'
Additional context
This was originally reported in dotnet/efcore#28185, which was later closed by dotnet/efcore#28253. This was in the 7.0.0 milestone which I believe means the standard tooling is already handling this, but Handlebars is not. I believe this area in HbsCSharpDbContextGenerator.cs corresponds with this area in CSharpDbContextGenerator.cs where the bulk of the changes appear to be (based on the pull request).
I apologize for the lack of a pull request since it feels like I'm about 75% of the way there, but I don't feel like I'm familiar enough with the internal workings of Handlebars to know what else might also need to be updated. Also, the v7.0.0 version of CSharpDbContextGenerator.cs looks completely different from the file originally included in the pull request, which has me a little puzzled (the current file appears to be generated and doesn't have the GenerateEntityType() method where changes were made).
The text was updated successfully, but these errors were encountered:
For anyone else that might have ran into this, it might also be worth pointing out that the breaking changes documentation has a Mitigations section that includes a pretty simple workaround.
Describe the bug
Scaffolding the DbContext/models with a SQL table that has a trigger does not generate
HasTrigger()
per a breaking change in EF7. As a result, a DbUpdateException occurs when saving changes that would cause the SQL trigger to fire.Expected behavior
HasTrigger()
should be generated when needed and changes should save without throwing an exception.To Reproduce
HasTrigger()
.Additional context
This was originally reported in dotnet/efcore#28185, which was later closed by dotnet/efcore#28253. This was in the 7.0.0 milestone which I believe means the standard tooling is already handling this, but Handlebars is not. I believe this area in HbsCSharpDbContextGenerator.cs corresponds with this area in CSharpDbContextGenerator.cs where the bulk of the changes appear to be (based on the pull request).
I apologize for the lack of a pull request since it feels like I'm about 75% of the way there, but I don't feel like I'm familiar enough with the internal workings of Handlebars to know what else might also need to be updated. Also, the v7.0.0 version of CSharpDbContextGenerator.cs looks completely different from the file originally included in the pull request, which has me a little puzzled (the current file appears to be generated and doesn't have the
GenerateEntityType()
method where changes were made).The text was updated successfully, but these errors were encountered: