using Microsoft.EntityFrameworkCore; using VberAdmin.EntityFrameworkCore; namespace VberAdmin.Seed; public static class ExecuteSql { public static void TruncateTable(this VberAdminDbContext context, string tableName) { if (string.IsNullOrEmpty(tableName)) { return; } var sql = $"TRUNCATE TABLE {tableName}"; context.Sql(sql); } public static void DeleteTable(this VberAdminDbContext context, string tableName) { if (string.IsNullOrEmpty(tableName)) { return; } var sql = $"DELETE FROM {tableName}"; context.Sql(sql); } public static void Sql(this VberAdminDbContext context, string sql) { if (string.IsNullOrEmpty(sql)) { return; } context.Database.ExecuteSqlRaw(sql); } }