none
DbContext.Savechanges() throwing error in entity frameworkcore7 with trigger for a table in sql RRS feed

  • Question

  • I have a table in sql server which is having a trigger when i insert data using dbcontext.savechanges() with entityframework7(core).It's  throwing error like The target table 'tablename' of the DML statement cannot have any enabled triggers if the statement contains an OUTPUT clause without INTO clause.Can you help me how to resolve

    Thanks&Rds,

    Raghu S

    • Moved by Bob Beauchemin Monday, August 1, 2016 3:19 PM Moved to entity framework-specific forum
    Monday, August 1, 2016 5:06 AM

Answers

  • The error you posted is a SQL error. The message is quite obvious and it means that the query you're using has an OUTPUT clause specified to capture the return values and it seems table already have a trigger enabled on it. If trigger is already present you will not be able to use OUTPUT clause in queries to capture the details from INSERTED and DELETED internal tables during a data manipulation operation. This is exactly what the error says

    So you have two options

    1. Use query without return value logic ie OUTPUT clause

    2. Disable the trigger on the table before query execution and enable it back after


    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    ----------------------------
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

    Monday, August 1, 2016 5:38 AM