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 lines
856B

  1. using Microsoft.EntityFrameworkCore;
  2. using Microsoft.EntityFrameworkCore.Design;
  3. using Microsoft.Extensions.Configuration;
  4. using ReAct_PME.Infrastructure.Persistence;
  5. namespace ReAct_PME.Infrastructure
  6. {
  7. public partial class AppDbContextFactory : IDesignTimeDbContextFactory<AppDbContext>
  8. {
  9. public AppDbContext CreateDbContext(string[] args)
  10. {
  11. string path = Path.Combine(Directory.GetCurrentDirectory(), "../ReAct_PME.Api");
  12. var configuration = new ConfigurationBuilder()
  13. .SetBasePath(path) // Accède au projet API
  14. .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
  15. .Build();
  16. var optionsBuilder = new DbContextOptionsBuilder<AppDbContext>();
  17. optionsBuilder.UseSqlServer(configuration.GetConnectionString("DefaultConnection"));
  18. return new AppDbContext(optionsBuilder.Options);
  19. }
  20. }
  21. }