Closed kolkinn closed 2 years ago
Apparently there's an option to make the cursor local, because now it seems global: https://stackoverflow.com/a/3524875/2672235
I managed to fix that by creating a class cloned from SqlServerTriggerVisitor
and changing the cursor declaration to
return $"DECLARE {cursorName} CURSOR LOCAL FOR";
then in the DbContext I replaced the service with mine:
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) {
optionsBuilder.UseSqlServer(@"...").UseSqlServerTriggers(services => services.AddScoped<ITriggerVisitor, SqlServerTriggerVisitorFix>());
}
And it seems to work
Thank you for the workaround, @Xriuk! It worked very well.
Hi. I have two triggers on an entity, one
AfterInsert(t => t.Action(a => a.Update(...)))
and oneAfterUpdate(t => t.Action(a => a.Update(...)))
. These both get the same cursor nameInserted<ENTITY_NAME>Cursor
. This causes an error when I try to insert a row to the table:Am I doing something wrong, or should each trigger instead be gettting their own uniquely named cursor?
My simple scenario here is setting a CreatedDate after insert and ModifiedDate after update.