none
Entity Framework Core 2.0 RRS feed

  • Question

  • Hi All,

    I am new to Entity Framework core Code first migrations and also naive with .Net Core. 

    I have been struggling to find out a solution to a problem i am facing the whole day. I want to roll back the database changes to a previous version of successful migration using the "Update-Database AlterColumnForOrdersTable" PMC command, but in vain. It gives me the below error

    Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[0]
          User profile is available. Using 'C:\Users\ShilpaNac\AppData\Local\ASP.NET\DataProtection-Keys' as key repository and Windows DPAPI to encrypt keys at rest.
    Microsoft.EntityFrameworkCore.Infrastructure[10403]
          Entity Framework Core 2.1.1-rtm-30846 initialized 'NorthwindDBcontext' using provider 'Microsoft.EntityFrameworkCore.SqlServer' with options: None
    Microsoft.EntityFrameworkCore.Database.Command[20101]
          Executed DbCommand (11ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
          SELECT OBJECT_ID(N'__EFMigrationsHistory');
    Microsoft.EntityFrameworkCore.Database.Command[20101]
          Executed DbCommand (3ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
          SELECT OBJECT_ID(N'__EFMigrationsHistory');
    Microsoft.EntityFrameworkCore.Database.Command[20101]
          Executed DbCommand (3ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
          SELECT [MigrationId], [ProductVersion]
          FROM [__EFMigrationsHistory]
          ORDER BY [MigrationId];
    Reverting migration '20180725095257_AddCustomers'.
    Microsoft.EntityFrameworkCore.Migrations[20401]
          Reverting migration '20180725095257_AddCustomers'.
    System.ArgumentNullException: Value cannot be null.
    Parameter name: name
       at Microsoft.EntityFrameworkCore.Utilities.Check.NotEmpty(String value, String parameterName)
       at Microsoft.EntityFrameworkCore.Storage.RelationalSqlGenerationHelper.DelimitIdentifier(String name, String schema)
       at Microsoft.EntityFrameworkCore.Migrations.SqlServerMigrationsSqlGenerator.Generate(DropIndexOperation operation, IModel model, MigrationCommandListBuilder builder, Boolean terminate)
       at Microsoft.EntityFrameworkCore.Migrations.SqlServerMigrationsSqlGenerator.Generate(DropIndexOperation operation, IModel model, MigrationCommandListBuilder builder)
       at Microsoft.EntityFrameworkCore.Migrations.MigrationsSqlGenerator.<>c.<.cctor>b__72_13(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(IReadOnlyList`1 operations, IModel model)
       at Microsoft.EntityFrameworkCore.Migrations.SqlServerMigrationsSqlGenerator.Generate(IReadOnlyList`1 operations, IModel model)
       at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.GenerateDownSql(Migration migration, Migration previousMigration)
       at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.<>c__DisplayClass13_1.<GetMigrationCommandLists>b__1()
       at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.Migrate(String targetMigration)
       at Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations.UpdateDatabase(String targetMigration, String contextType)
       at Microsoft.EntityFrameworkCore.Design.OperationExecutor.UpdateDatabase.<>c__DisplayClass0_1.<.ctor>b__0()
       at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)

    Please help me by providing a solution/workaround. Please let me know in-case you further require more details.

    Thanks,

    • Moved by ahmedilyas Wednesday, July 25, 2018 4:01 PM Better suited in this forum as it is more focused on ADO.NET/EF
    Wednesday, July 25, 2018 2:20 PM

All replies

  • Hi Nash76,

    I would suggest that you could share a simple demo and related steps, which could reproduce the issue on my side. 

    Best regards,

    Zhanglong


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, July 26, 2018 7:04 AM
    Moderator