临河任务调度
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 line
895B

  1. using System.IO;
  2. using Microsoft.EntityFrameworkCore;
  3. using Microsoft.EntityFrameworkCore.Design;
  4. using Microsoft.Extensions.Configuration;
  5. namespace Himp.TaskScheduling.EntityFrameworkCore;
  6. public class AuthServerDbContextFactory : IDesignTimeDbContextFactory<AuthServerDbContext>
  7. {
  8. public AuthServerDbContext CreateDbContext(string[] args)
  9. {
  10. var configuration = BuildConfiguration();
  11. var builder = new DbContextOptionsBuilder<AuthServerDbContext>()
  12. .UseSqlServer(configuration.GetConnectionString("Default"));
  13. return new AuthServerDbContext(builder.Options);
  14. }
  15. private static IConfigurationRoot BuildConfiguration()
  16. {
  17. var builder = new ConfigurationBuilder()
  18. .SetBasePath(Directory.GetCurrentDirectory())
  19. .AddJsonFile("appsettings.json", optional: false);
  20. return builder.Build();
  21. }
  22. }