Почему (SQL severtrigger) не срабатывает после вставки с помощью entity framework?
I have an c# application using Entity Framework and i create a trigger in the database fired after inserting , updating. I notice that the trigger does not fired when i insert or update using EF code, on the other side the trigger fired when i insert or update through sql server
Что я уже пробовал:
USE [HrProject] GO /****** Object: Trigger [dbo].[updateLoanFinishing] Script Date: 18/12/2016 8:24:49 ص ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER TRIGGER [dbo].[updateLoanFinishing] ON [dbo].[Installments_Paids] AFTER INSERT , UPDATE , DELETE AS BEGIN DECLARE @totalLoan decimal , @totalpaid decimal , @balance decimal SELECT @totalLoan = l.Total_Amount FROM dbo.Loans l SELECT @totalpaid = ISNULL(SUM(ip.Paid_Amount) ,0) FROM dbo.Installments_Paids ip SELECT @balance = @totalLoan - @totalpaid IF @balance = 0 BEGIN UPDATE dbo.Loans SET dbo.Loans.IsFinish = 1 -- bit FROM dbo.Loans l INNER JOIN INSERTED i ON i.Loan_ID = l.Loan_ID END ELSE IF @balance >0 BEGIN UPDATE dbo.Loans SET dbo.Loans.IsFinish = 0 -- bit FROM dbo.Loans l INNER JOIN INSERTED i ON i.Loan_ID = l.Loan_ID END END
Mohtshm Zubair
изначально триггеры не активны и не включены. Поэтому выберите из Обозревателя объектов и сделайте их активными
Ahmed Dabas
Триггер уже включен