question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error when removing-migration

See original GitHub issue

Describe the bug An error occurs when removing a previous created migration. Error: A relational store has been configured without specifying either the DbConnection or connection string to use.

To Reproduce Steps to reproduce the behavior:

  1. Open Package Manger Console in Visual Studio
  2. Create a new migration using the following command:
    add-migration AddSortOrder -context ApplicationDbContext -project Migrators.MSSQL -outputdir Migrations\Application -args “–provider SqlServer”
  3. Remove migration using the following command: remove-migration -context ApplicationDbContext -project Migrators.MSSQL -args “–provider SqlServer”
  4. Following error occurs:

System.InvalidOperationException: A relational store has been configured without specifying either the DbConnection or connection string to use. at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.get_DbConnection() at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.Open(Boolean errorsExpected) at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerDatabaseCreator.<>c__DisplayClass18_0.<Exists>b__0(DateTime giveUp) at Microsoft.EntityFrameworkCore.ExecutionStrategyExtensions.<>c__DisplayClass12_02.<Execute>b__0(DbContext c, TState s) at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.Execute[TState,TResult](TState state, Func3 operation, Func3 verifySucceeded) at Microsoft.EntityFrameworkCore.ExecutionStrategyExtensions.Execute[TState,TResult](IExecutionStrategy strategy, TState state, Func2 operation, Func2 verifySucceeded) at Microsoft.EntityFrameworkCore.ExecutionStrategyExtensions.Execute[TState,TResult](IExecutionStrategy strategy, TState state, Func2 operation) at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerDatabaseCreator.Exists(Boolean retryOnNotExists) at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerDatabaseCreator.Exists() at Microsoft.EntityFrameworkCore.Migrations.HistoryRepository.Exists() at Microsoft.EntityFrameworkCore.Migrations.HistoryRepository.GetAppliedMigrations() at Microsoft.EntityFrameworkCore.Migrations.Design.MigrationsScaffolder.RemoveMigration(String projectDir, String rootNamespace, Boolean force, String language) at Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations.RemoveMigration(String contextType, Boolean force) at Microsoft.EntityFrameworkCore.Design.OperationExecutor.RemoveMigrationImpl(String contextType, Boolean force) at Microsoft.EntityFrameworkCore.Design.OperationExecutor.RemoveMigration.<>c__DisplayClass0_0.<.ctor>b__0() at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.<>c__DisplayClass3_0`1.<Execute>b__0() at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action) A relational store has been configured without specifying either the DbConnection or connection string to use.

Expected behavior Migration is removed.

Screenshots image

Desktop (please complete the following information):

  • Windows 10

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
m-claescommented, Sep 22, 2021

Hi, first let me thank you for your quick response and work on this project. Your proposed solution seems like a viable workaround. If the migration is not yet applied to the database a simple ‘Undo changes’ on Git could also undo the migration.

I haven’t been able to test the other featurese like token generation/endpoints as I was only working on the migrations part for a multi-tenant project (based on you article).

0reactions
1dveerancommented, Dec 3, 2021

Sure I will try this. Thank you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Entity Framework rollback and remove bad migration
If you havent yet applied the bad migration theres nothing stopping you either deleting it and rescaffolding or correcting the broken migration.
Read more >
Remove migration does not remove unapplied ...
2. The following error is thrown when attempting to remove an unapplied migration: The migration '<previous_migration_name>' has already been applied to the ...
Read more >
Managing Migrations - EF Core
In your database, delete all rows from the migrations history table (e.g. DELETE FROM [__EFMigrationsHistory] on SQL Server). Delete your ...
Read more >
updating migration while removing a column - Microsoft Q&A
hello, I am using visual studio with SQL server, i am in a middle of a practice and faced a major issue. The...
Read more >
Entity Framework Core Migrations
The following command removes a migration: ... You will use this command to remove the latest migration. This will remove the class file...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found