diff --git a/Shogi/BackEnd/Identity/ApplicationDbContextFactory.cs b/Shogi/BackEnd/Identity/ApplicationDbContextFactory.cs new file mode 100644 index 0000000..47b7de8 --- /dev/null +++ b/Shogi/BackEnd/Identity/ApplicationDbContextFactory.cs @@ -0,0 +1,18 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Design; + +namespace Shogi.BackEnd.Identity; + +public class ApplicationDbContextFactory : IDesignTimeDbContextFactory +{ + public ApplicationDbContext CreateDbContext(string[] args) + { + var optionsBuilder = new DbContextOptionsBuilder(); + + // 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); + } +}