Entity Framework 6 / SQL Server triggers - getting error

0

I have an EF6 solution that I would like to add a trigger on a table to log changes to a new table. This is due to an integration we are doing to an external database. Basically, they want a log of changes that are made to a table for sync purposes.

The triggers work perfectly when I execute through SSMS (Azure SQL DB), but when I test via our web app I get the following error:

(0x80131904): The target table 'DestinationTable' of the DML statement cannot have any enabled triggers if the statement contains an OUTPUT clause without INTO clause.

Basically, it looks like I can't assign a trigger to a table that uses Entity Framework.

Anyone have ideas for how to make this work?

Thanks in advance

c#
sql-server
entity-framework
azure-sql-database
asked on Stack Overflow Jan 25, 2021 by Shawn Dillon • edited Jan 25, 2021 by marc_s

1 Answer

0

I have found the issue, and it is related to an extension package that we are using called ZEntity.BulkOperations.Extension. David Browne's comments made me log the error and an inner exception pointed to the ZEntity BulkInsert as the error. I then discovered this link https://github.com/zzzprojects/EntityFramework-Extensions/issues/334 , which pointed out that this package DID handle triggers. All I had to do was to stop and restart the services using the db and the package, so that the newly added trigger would be discovered by ZEntity.

TLDR; I just had to stop and start the services to make the ZEntity package aware of the added trigger.

Thank you to all who answered!

answered on Stack Overflow Jan 26, 2021 by Shawn Dillon

User contributions licensed under CC BY-SA 3.0