Does anyone knows in C# ASP.NET Core 3.1 why statement after the commented one in the following code does not work? entityFramework core throws an exception
fail: Microsoft.EntityFrameworkCore.Database.Command[20102]
Failed executing DbCommand (44ms) [Parameters=[@p0='?' (Size = 4000)], CommandType='Text', CommandTimeout='30']
SET IDENTITY_INSERT @p0 ON;
By the way, commented statement works. And I am not running 2 statement together.
var tableName = "discountTypes";
using (var transaction = context.Database.BeginTransaction())
{
// context.Database.ExecuteSqlInterpolated($"SET IDENTITY_INSERT discountTypes ON;");
context.Database.ExecuteSqlInterpolated($"SET IDENTITY_INSERT {tableName} ON;");
await context.SaveChangesAsync();
context.Database.ExecuteSqlInterpolated($"SET IDENTITY_INSERT discounTypes OFF;");
transaction.Commit();
}
Thank you.
-Tony