How to make Entity Framework 7 not use OUTPUT in updates?
Asked Answered
A

1

6

I get this error when I update through EF 7: "The target table 'Table' of the DML statement cannot have any enabled triggers if the statement contains an OUTPUT clause without INTO clause."

EF 7 executes this:

exec sp_executesql N'SET IMPLICIT_TRANSACTIONS OFF;
SET NOCOUNT ON;
UPDATE [ObrazacZahtjevZaIzvanrednuPozajmicu] SET [OdbijenOdobren] = @p0
OUTPUT 1
WHERE [ObrazacZahtjevZaIzvanrednuPozajmicuId] = @p1 AND [Zakljucan] = @p2;
',N'@p1 int,@p0 bit,@p2 bit',@p1=21858,@p0=1,@p2=0
Ardolino answered 20/12, 2022 at 11:54 Comment(1)
@ErmiyaEskandary No example code is needed, any update would cause this.Jessi
J
9

You need to tell EF that the table has a trigger. So in the OnModelCreating in your context, you use something like this:

modelBuilder
    .Entity<TableWithTrigger>()
    .ToTable(t => t.HasTrigger("NameOfTrigger"));

For info, this was documented in Breaking changes in EF Core 7.0 (EF7)

Jessi answered 20/12, 2022 at 12:9 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.