Open Closed

Getting error to run DBMigrator after deleting old Database. Error in await ((DbContext)_serviceProvider.GetRequiredService(dbContextType)) .Database .MigrateAsync(); #9180


User avatar
0
sghorakavi@cpat.com created
  • *Steps to reproduce the issue
  • Dropped Database and trying to recreate the same DB Getting error during DBMigrator run. I do not know which code need to be cleared. My database is empty. MSSQL:

PS C:\develop\AccessBanyan\TMS_MVC\src\TMS_MVC.DbMigrator> dotnet run C:\develop\AccessBanyan\TMS_MVC\src\TMS_MVC.EntityFrameworkCore\Migrations\20250422173907_update.cs(9,26): warning CS8981: The type name 'update' only contains lower-cased ascii characters. Such names may become reserved for the language. C:\develop\AccessBanyan\TMS_MVC\src\TMS_MVC.EntityFrameworkCore\Migrations\20250422173907_update.Designer.cs(18,19): warning CS8981: The type name 'update' only contains lower-cased ascii characters. Such names may become reserved for the language. [17:02:03 INF] Started database migrations... [17:02:03 INF] Migrating schema for host database... Unhandled exception. System.InvalidOperationException: To change the IDENTITY property of a column, the column needs to be dropped and recreated. at Microsoft.EntityFrameworkCore.Migrations.SqlServerMigrationsSqlGenerator.Generate(AlterColumnOperation operation, IModel model, MigrationCommandListBuilder builder) at Microsoft.EntityFrameworkCore.Migrations.MigrationsSqlGenerator.<>c.<.cctor>b__83_4(MigrationsSqlGenerator g, MigrationOperation o, IModel m, MigrationCommandListBuilder b) at Microsoft.EntityFrameworkCore.Migrations.MigrationsSqlGenerator.Generate(MigrationOperation operation, IModel model, MigrationCommandListBuilder builder) at Microsoft.EntityFrameworkCore.Migrations.SqlServerMigrationsSqlGenerator.Generate(MigrationOperation operation, IModel model, MigrationCommandListBuilder builder) at Microsoft.EntityFrameworkCore.Migrations.MigrationsSqlGenerator.Generate(IReadOnlyList1 operations, IModel model, MigrationsSqlGenerationOptions options) at Microsoft.EntityFrameworkCore.Migrations.SqlServerMigrationsSqlGenerator.Generate(IReadOnlyList1 operations, IModel model, MigrationsSqlGenerationOptions options) at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.GenerateUpSql(Migration migration, MigrationsSqlGenerationOptions options) at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.<>c__DisplayClass24_2.<GetMigrationCommandLists>b__2()

Error: - $exception {"To change the IDENTITY property of a column, the column needs to be dropped and recreated."} System.InvalidOperationException I do not have any tables now. Even cleared cache


1 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Can you try to use a new database name?

    Thanks.

Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.0.0-preview. Updated on September 01, 2025, 08:37