DesignTimeDbContextFactory.cs 784 B

1234567891011121314151617181920212223
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using Microsoft.EntityFrameworkCore;
  5. using Microsoft.EntityFrameworkCore.Design;
  6. using Microsoft.EntityFrameworkCore.Infrastructure;
  7. namespace Application.ATG_Classic_App
  8. {
  9. /// <summary>
  10. /// Visual studio Add-Migration will detect and use this to get DbContext
  11. /// </summary>
  12. public class DesignTimeDbContextFactory : IDesignTimeDbContextFactory<AppDbContext>
  13. {
  14. public AppDbContext CreateDbContext(string[] args)
  15. {
  16. var option = new DbContextOptionsBuilder<AppDbContext>()
  17. .UseSqlite("Data Source=Application.ATG_Classic_App_database.db").Options;
  18. return new AppDbContext(option);
  19. return new AppDbContext();
  20. }
  21. }
  22. }