| 1234567891011121314151617181920212223242526 |
- using Microsoft.EntityFrameworkCore;
- using Microsoft.EntityFrameworkCore.Design;
- using Microsoft.EntityFrameworkCore.Diagnostics;
- namespace Infrastructure.Persistence;
- /// <summary>
- /// Design-time DbContext factory for IdentityDbContext.
- /// See <see cref="AppDbContextDesignTimeFactory"/> for rationale.
- /// </summary>
- public sealed class IdentityDbContextDesignTimeFactory : IDesignTimeDbContextFactory<IdentityDbContext>
- {
- public IdentityDbContext CreateDbContext(string[] args)
- {
- var conn = Environment.GetEnvironmentVariable("ConnectionStrings__IdentityDbContextConnection")
- ?? Environment.GetEnvironmentVariable("ConnectionStrings__DefaultConnection")
- ?? "Server=.\\SQLEXPRESS;Database=dpot;Trusted_Connection=True;TrustServerCertificate=True;MultipleActiveResultSets=true";
- var options = new DbContextOptionsBuilder<IdentityDbContext>()
- .UseSqlServer(conn)
- .ConfigureWarnings(w => w.Ignore(RelationalEventId.PendingModelChangesWarning))
- .Options;
- return new IdentityDbContext(options);
- }
- }
|