Add-Migration InitialCreate throws an exception, but is successful

David Thielen 3,211 Reputation points
2023-10-05T00:59:56.8933333+00:00

When I run Add-Migration InitialCreate it successfully creates the EF classes. But it also throws the following exception:

PM> Add-Migration InitialCreate  -context TrackingDbContext
Build started...
Build succeeded.
{"EventId":0,"LogLevel":"Information","Category":"LouisHowe.web.Program","Message":"Application starting up","State":{"Message":"Application starting up","{OriginalFormat}":"Application starting up"}}
{"EventId":0,"LogLevel":"Critical","Category":"LouisHowe.web.Program","Message":"Unhandled exception in Main()","Exception":"Microsoft.Extensions.Hosting.HostAbortedException: The host was aborted.    at Microsoft.Extensions.Hosting.HostFactoryResolver.HostingListener.ThrowHostAborted()    at Microsoft.Extensions.Hosting.HostFactoryResolver.HostingListener.OnNext(KeyValuePair\u00602 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 LouisHowe.web.Program.Main(String[] args) in C:\\Git\\LouisHowe\\LouisHowe.web\\Program.cs:line 220","State":{"Message":"Unhandled exception in Main()","{OriginalFormat}":"Unhandled exception in Main()"}}
To undo this action, use Remove-Migration.
PM> 

What's going on here? And how do I avoid this exception?

thanks - dave

Developer technologies .NET Entity Framework Core
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.