I'm trying to add a migration via Add-Migration {Name}
or dotnet ef migrations add {Name}
with a .NET 6 Worker Service. It build successfully and I can see from the migration logs its trying to but just dies silently at
Using application service provider from Microsoft.Extensions.Hosting.
Here's the full stack log once it finishes building
dotnet exec --depsfile C:\Users\me\source\repos\SmartSafeFinancials\src\StoresDaysheetProcessor.Worker\bin\Debug\net6.0\StoresDaysheetProcessor.Worker.deps.json --additionalprobingpath C:\Users\me\.nuget\packages --runtimeconfig C:\Users\me\source\repos\SmartSafeFinancials\src\StoresDaysheetProcessor.Worker\bin\Debug\net6.0\StoresDaysheetProcessor.Worker.runtimeconfig.json C:\Users\me\.dotnet\tools\.store\dotnet-ef\6.0.2\dotnet-ef\6.0.2\tools\netcoreapp3.1\any\tools\netcoreapp2.0\any\ef.dll migrations add Initialcreate -o ./Data/SmartSafeFinancials/Migrations --context SmartSafeFinancialsDbContext --assembly C:\Users\me\source\repos\SmartSafeFinancials\src\StoresDaysheetProcessor.Worker\bin\Debug\net6.0\StoresDaysheetProcessor.Worker.dll --project C:\Users\me\source\repos\SmartSafeFinancials\src\StoresDaysheetProcessor.Worker\StoresDaysheetProcessor.Worker.csproj --startup-assembly C:\Users\me\source\repos\SmartSafeFinancials\src\StoresDaysheetProcessor.Worker\bin\Debug\net6.0\StoresDaysheetProcessor.Worker.dll --startup-project C:\Users\me\source\repos\SmartSafeFinancials\src\StoresDaysheetProcessor.Worker\StoresDaysheetProcessor.Worker.csproj --project-dir C:\Users\me\source\repos\SmartSafeFinancials\src\StoresDaysheetProcessor.Worker\ --root-namespace StoresDaysheetProcessor.Worker --language C# --framework net6.0 --nullable --working-dir C:\Users\me\source\repos\SmartSafeFinancials\src\StoresDaysheetProcessor.Worker --verbose
Using assembly 'StoresDaysheetProcessor.Worker'.
Using startup assembly 'StoresDaysheetProcessor.Worker'.
Using application base 'C:\Users\me\source\repos\SmartSafeFinancials\src\StoresDaysheetProcessor.Worker\bin\Debug\net6.0'.
Using working directory 'C:\Users\me\source\repos\SmartSafeFinancials\src\StoresDaysheetProcessor.Worker'.
Using root namespace 'StoresDaysheetProcessor.Worker'.
Using project directory 'C:\Users\me\source\repos\SmartSafeFinancials\src\StoresDaysheetProcessor.Worker\'.
Remaining arguments: .
Finding DbContext classes...
Finding IDesignTimeDbContextFactory implementations...
Finding application service provider in assembly 'StoresDaysheetProcessor.Worker'...
Finding Microsoft.Extensions.Hosting service provider...
Using environment 'Development'.
Using application service provider from Microsoft.Extensions.Hosting.
Database context
public class SmartSafeFinancialsDbContext : DbContext
{
public SmartSafeFinancialsDbContext(DbContextOptions<SmartSafeFinancialsDbContext> options) : base(options)
{
}
public DbSet<StoreDaysheetDay> StoreDaysheetDays { get; set; } = null!;
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
}
}
Program.cs
var builder = Host.CreateDefaultBuilder(args)
.ConfigureServices((builder, services) =>
{
services.AddDbContextFactory<SmartSafeFinancialsDbContext>(options =>
{
options.UseSqlServer(_configuration.GetConnectionString("SmartSafeFinancials"));
});
});
var host = builder.Build();
await host.RunAsync();