Add IDesignTimeDbContextFactory for pipeline EF bundle

This commit is contained in:
2026-01-26 19:19:57 -06:00
parent 7f3cbcfdef
commit 1bcd8ed2ac

View File

@@ -0,0 +1,18 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
namespace Shogi.BackEnd.Identity;
public class ApplicationDbContextFactory : IDesignTimeDbContextFactory<ApplicationDbContext>
{
public ApplicationDbContext CreateDbContext(string[] args)
{
var optionsBuilder = new DbContextOptionsBuilder<ApplicationDbContext>();
// This connection string is strictly for design-time tools (like creating migrations).
// It is NOT used when running the app or when applying the migration bundle.
optionsBuilder.UseSqlServer("Server=(localdb)\\mssqllocaldb;Database=ShogiDb;Trusted_Connection=True;MultipleActiveResultSets=true");
return new ApplicationDbContext(optionsBuilder.Options);
}
}