Изменения

This commit is contained in:
2025-05-15 01:37:27 +04:00
parent 995029ce8d
commit 2b61669e7a
36 changed files with 200 additions and 360 deletions
+2 -2
View File
@@ -69,7 +69,7 @@ public static class EfCleanHelper
public static string Truncate<T>(this DbSet<T> dbSet)
where T : class
{
string cmd = $"TRUNCATE TABLE {TableName(dbSet)} CASCADE;";
string cmd = $"TRUNCATE TABLE {TableName(dbSet)} RESTART IDENTITY CASCADE;";
DbContext context = dbSet.GetService<ICurrentDbContext>().Context;
context.Database.ExecuteSqlRaw(cmd);
return cmd;
@@ -87,7 +87,7 @@ public static class EfCleanHelper
foreach (IEntityType entityType in tables)
{
string cmd = $"TRUNCATE TABLE {GetName(entityType)} CASCADE;";
string cmd = $"TRUNCATE TABLE {GetName(entityType)} RESTART IDENTITY CASCADE;";
context.Database.ExecuteSqlRaw(cmd);
cmdList.Add(cmd);
}