Add IDesignTimeDbContextFactory for pipeline EF bundle
This commit is contained in:
18
Shogi/BackEnd/Identity/ApplicationDbContextFactory.cs
Normal file
18
Shogi/BackEnd/Identity/ApplicationDbContextFactory.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user