fullstackhero / dotnet-starter-kit

Production Grade Cloud-Ready .NET 8 Starter Kit (Web API + Blazor Client) with Multitenancy Support, and Clean/Modular Architecture that saves roughly 200+ Development Hours! All Batteries Included.
https://fullstackhero.net/dotnet-webapi-boilerplate/
MIT License
5.07k stars 1.52k forks source link

Getting Error While Adding Migrations or Updating Database, however migrations executed successfully #859

Closed devdgupta closed 1 year ago

devdgupta commented 1 year ago

Describe the bug

When I am trying to add the migrations, I am getting Host was aborted error message, however migrations are added successfully. Same goes for while Updating the database after adding migrations.

Command for Adding Migrations. dotnet ef migrations add ABCAdded --project .././Migrators/Migrators.MSSQL/ --context ApplicationDbContext -o Migrations/Application

Build started... Build succeeded. [10:15:16 INF] Server Booting Up... [10:15:18 INF] Hangfire: Current Storage Provider : mssql [10:15:18 INF] For more Hangfire storage, visit https://www.hangfire.io/extensions.html

[10:15:27 INF] Current DB Provider: mssql [10:15:27 FTL] Unhandled exception Microsoft.Extensions.Hosting.HostAbortedException: The host was aborted. at Microsoft.Extensions.Hosting.HostFactoryResolver.HostingListener.ThrowHostAborted() at Microsoft.Extensions.Hosting.HostFactoryResolver.HostingListener.OnNext(KeyValuePair`2 value) at System.Diagnostics.DiagnosticListener.Write(String name, Object value) at Microsoft.Extensions.Hosting.HostBuilder.ResolveHost(IServiceProvider serviceProvider, DiagnosticListener diagnosticListener) at Microsoft.Extensions.Hosting.HostApplicationBuilder.Build() at Microsoft.AspNetCore.Builder.WebApplicationBuilder.Build() at Program.

$(String[] args) in \src\Host\Program.cs:line 23 [10:15:27 INF] Server Shutting down... An operation was scaffolded that may result in the loss of data. Please review the migration for accuracy. Done. To undo this action, use 'ef migrations remove'.


Command for Updating the Database

dotnet ef database update --project .././Migrators/Migrators.MSSQL/ --context ApplicationDbContext Build started... Build succeeded. [10:22:34 INF] Server Booting Up... [10:22:38 INF] Hangfire: Current Storage Provider : mssql [10:22:38 INF] For more Hangfire storage, visit https://www.hangfire.io/extensions.html

[10:22:52 INF] Current DB Provider: mssql [10:22:52 FTL] Unhandled exception Microsoft.Extensions.Hosting.HostAbortedException: The host was aborted. at Microsoft.Extensions.Hosting.HostFactoryResolver.HostingListener.ThrowHostAborted() at Microsoft.Extensions.Hosting.HostFactoryResolver.HostingListener.OnNext(KeyValuePair`2 value) at System.Diagnostics.DiagnosticListener.Write(String name, Object value) at Microsoft.Extensions.Hosting.HostBuilder.ResolveHost(IServiceProvider serviceProvider, DiagnosticListener diagnosticListener) at Microsoft.Extensions.Hosting.HostApplicationBuilder.Build() at Microsoft.AspNetCore.Builder.WebApplicationBuilder.Build() at Program.

$(String[] args) in \src\Host\Program.cs:line 23 [10:22:52 INF] Server Shutting down... Done.

below is the code on line number 23 in Program.cs var app = builder.Build();

To Reproduce Steps to reproduce the behavior:

  1. Add any new POCO model
  2. Added mapping for configuration inherited from IEntityTypeConfiguration
  3. run command for add migration
  4. update database

Expected behavior Host was aborted error message must not appear

Stack Trace Stack trace shared above

Any feedback on this would be greatly appreciated.

iammukeshm commented 1 year ago

this is already fixed here - https://github.com/fullstackhero/dotnet-webapi-boilerplate/commit/bb045603d8f0b5e2623fc1d799ac1f4ff9b3b474

You can adapt to these changes. The next release will have this fix included.

devdgupta commented 1 year ago

Thanks for the update