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.

Home Page:https://fullstackhero.net/dotnet-webapi-boilerplate/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

devdgupta opened this issue · comments

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.

this is already fixed here - bb04560

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

Thanks for the update