On Running dotnet ef database drop
I get an error. How can I debug this command, to get more details about the problem? Or how can I find the source of this error?
System.ObjectDisposedException: Cannot access a disposed object. A common cause of this error is disposing a context that was resolved from dependency injection and then later trying to use the same context instance elsewhere in your application. This may occur if you are calling Dispose() on the context, or wrapping the context in a using statement. If you are using dependency injection, you should let the dependency injection container take care of disposing context instances. Objektname: "ApplicationDbContext". bei Microsoft.EntityFrameworkCore.DbContext.get_InternalServiceProvider() bei Microsoft.EntityFrameworkCore.DbContext.Microsoft.EntityFrameworkCore.Infrastructure.IInfrastructure.get_Instance() bei Microsoft.EntityFrameworkCore.Infrastructure.AccessorExtensions.GetService[TService](IInfrastructure
1 accessor) bei Microsoft.EntityFrameworkCore.Design.Internal.DbContextOperations.CreateContext(Func
1 factory) bei Microsoft.EntityFrameworkCore.Design.Internal.DbContextOperations.CreateContext(String contextType) bei Microsoft.EntityFrameworkCore.Design.Internal.DbContextOperations.DropDatabase(String contextType) bei Microsoft.EntityFrameworkCore.Design.OperationExecutor.DropDatabaseImpl(String contextType) bei Microsoft.EntityFrameworkCore.Design.OperationExecutor.DropDatabase.<>c__DisplayClass0_1.<.ctor>b__0() bei Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action) Cannot access a disposed object. A common cause of this error is disposing a context that was resolved from dependency injection and then later trying to use the same context instance elsewhere in your application. This may occur if you are calling Dispose() on the context, or wrapping the context in a using statement. If you are using dependency injection, you should let the dependency injection container take care of disposing context instances. Objektname: "ApplicationDbContext".
DbContext
get initialized? Are you migrating against a ASP.NET Core project or a class library? If it's ASP.NET Core, post yourStartup
class. If it's a class library, post yourIDesignTimeDbContextFactory
implementation. – Chris Pratt Dec 27 '17 at 15:25dotnet ef ...
in the debugger? – Sam Dec 27 '17 at 15:50