Open Closed

More than one DbContext was found. #2753


User avatar
0
improwise created

If you're creating a bug/problem report, please include followings:

  • ABP Framework version: 5.1.4
  • UI type: Angular
  • DB provider: EF Core

This problem seem to be back in 5.1.4

https://support.abp.io/QA/Questions/1662/More-than-one-DBContext-was-found

When following the instructions for

https://docs.abp.io/en/abp/latest/Tutorials/Todo/Index?UI=NG&DB=EF

(angular version)

you get:

More than one DbContext was found. Specify which one to use. Use the '-Context' parameter for PowerShell commands and the '--context' parameter for dotnet commands.

If you specify

Add-Migration Added_TodoItem -Context TodoAppDbContext

Migration is created but you still get an error:

Microsoft.Extensions.Hosting.HostFactoryResolver+HostingListener+StopTheHostException: Exception of type 'Microsoft.Extensions.Hosting.HostFactoryResolver+HostingListener+StopTheHostException' was thrown. at Microsoft.Extensions.Hosting.HostFactoryResolver.HostingListener.OnNext(KeyValuePair2 value) ` at System.Diagnostics.DiagnosticListener.Write(String name, Object value) at Microsoft.Extensions.Hosting.HostBuilder.Build() at Microsoft.AspNetCore.Builder.WebApplicationBuilder.Build() at TodoApp.Program.Main(String[] args) in *******\src\TodoApp\aspnet-core\src\TodoApp.HttpApi.Host\Program.cs:line 39 To undo this action, use Remove-Migration.``

(We are using Package Manage Console in VS)


6 Answer(s)
  • User Avatar
    0
    improwise created

    Note sure if this should be posted to GitHub Issues instead but it seems the "abp new TodoApp -u angular" command uses app-pro version which I recall is commercial one.

  • User Avatar
    0
    berkansasmaz created
    Support Team .NET Developer

    @EngincanV, can you test this situation with Package Manage Console in VS

  • User Avatar
    0
    improwise created

    Seems like this tutorial has more problems with 5.1.4, even when using the code from here:

    https://github.com/abpframework/abp-samples/tree/master/TodoApp.

    like ng build didn't seem to work either

    An unhandled exception occurred: ENOENT: no such file or directory, lstat '****\src\abp-samples-master\TodoApp\Angular-EfCore\angular\node_modules\bootstrap\dist\css\bootstrap.rtl.min.css'

    Seems like it is based on Angular 11.1.4.

  • User Avatar
    0
    EngincanV created
    Support Team .NET Developer

    Hi @improwise, I've just created an angular application and followed the steps that you've provided, but I didn't get any error and I could successfully create a migration even without specifying -Context parameter on Package Manager Console.

    And also I could successfully run the Angular side by following the documentation.

    Did you upgrade your application to v5.1.4 and what is your ng version?

  • User Avatar
    0
    improwise created

    Hi @improwise, I've just created an angular application and followed the steps that you've provided, but I didn't get any error and I could successfully create a migration even without specifying -Context parameter on Package Manager Console.

    And also I could successfully run the Angular side by following the documentation.

    Did you upgrade your application to v5.1.4 and what is your ng version?

    Not sure why but after having reinstalled Visual Studio, the migration problem seemed to go away. Still getting this though:

    An error occurred while accessing the Microsoft.Extensions.Hosting services. Continuing without the application service provider. Error: Unable to build IHost

    We never really bothered with angular for this sample, but it seems it is using Angular 11 in the samples so I guess it hasn't been updated in a while.

  • User Avatar
    0
    EngincanV created
    Support Team .NET Developer

    Not sure why but after having reinstalled Visual Studio, the migration problem seemed to go away.

    It's nice to hear the DB context problem is fixed.

    We never really bothered with angular for this sample, but it seems it is using Angular 11 in the samples so I guess it hasn't been updated in a while.

    Todo App sample is in the v5.0.0 right now, we try to keep our samples up to date and we usually update our samples after the stable releases. Thanks for your suggestion, we'll upgrade it asap.

Made with ❤️ on ABP v9.1.0-preview. Updated on December 13, 2024, 06:09