public void RunDbCpecificCode() { if (db.DataProvider.Name.StartsWith("PostgreSQL")) { Console.WriteLine("Update sequences for PostgreSQL"); string[] tablesWithSequenceIds = { "Categories", "AspNetUsers", "Materials", "Comments", "AspNetRoles", "CategoryAccesses", "Tags", "MenuItems", "Components" }; foreach (string tableName in tablesWithSequenceIds) { //Console.WriteLine($"Renew sequence of table: '{tableName}'"); db.Execute( $"SELECT setval(pg_get_serial_sequence('\"{tableName.ToSnakeCase()}\"', 'Id'), coalesce(max(tbl.\"{"Id".ToSnakeCase()}\"),0) + 1, false) FROM \"{tableName.ToSnakeCase()}\" as tbl;"); } db.Execute( $"SELECT setval(pg_get_serial_sequence('\"{"OperationKeys".ToSnakeCase()}\"', '{"OperationKeyId".ToSnakeCase()}'), coalesce(max(tbl.\"{"OperationKeyId".ToSnakeCase()}\"),0) + 1, false) FROM \"{"OperationKeys".ToSnakeCase()}\" as tbl;"); } }