ISMSDbContextFactory.cs 1.1 KB

1234567891011121314151617181920212223242526272829
  1. using CodeFirstExistingDatabaseSample.ISMS_BASE;
  2. using Microsoft.EntityFrameworkCore;
  3. using Microsoft.EntityFrameworkCore.Design;
  4. using Microsoft.Extensions.Configuration;
  5. using YunDa.ISAS.Core;
  6. using YunDa.ISAS.Core.Configuration;
  7. using YunDa.ISAS.Core.Web;
  8. namespace CodeFirstExistingDatabaseSample
  9. {
  10. /* This class is needed to run EF Core PMC commands. Not used anywhere else */
  11. public class ISMSDbContextFactory : IDesignTimeDbContextFactory<ISMS_BASEContext>
  12. {
  13. public ISMS_BASEContext CreateDbContext(string[] args)
  14. {
  15. var builder = new DbContextOptionsBuilder<ISMS_BASEContext>();
  16. var configuration = ISASConfiguration.Get(WebContentDirectoryFinder.CalculateContentRootFolder());
  17. DbContextOptionsConfigurer.Configure(
  18. builder,
  19. configuration.GetConnectionString(ISASConsts.ISMS_BASESqlServerSettingStringKey)
  20. );
  21. return new ISMS_BASEContext(builder.Options);
  22. }
  23. }
  24. /* This class is needed to run EF Core PMC commands. Not used anywhere else */
  25. }