File tree Expand file tree Collapse file tree
BervProject.WebApi.Boilerplate/Data Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ using BervProject . WebApi . Boilerplate . EntityFramework ;
2+ using Microsoft . EntityFrameworkCore ;
3+ using Microsoft . EntityFrameworkCore . Design ;
4+ using Microsoft . Extensions . Configuration ;
5+
6+ namespace BervProject . WebApi . Boilerplate . Data ;
7+
8+ public class DesignTimeDbContextFactory : IDesignTimeDbContextFactory < BoilerplateDbContext >
9+ {
10+ public BoilerplateDbContext CreateDbContext ( string [ ] args )
11+ {
12+ var configuration = new ConfigurationBuilder ( )
13+ . SetBasePath ( Directory . GetCurrentDirectory ( ) )
14+ . AddJsonFile ( "appsettings.json" )
15+ . Build ( ) ;
16+
17+ var optionsBuilder = new DbContextOptionsBuilder < BoilerplateDbContext > ( ) ;
18+ optionsBuilder . UseNpgsql ( configuration . GetConnectionString ( "BoilerplateConnectionString" ) ) ;
19+
20+ return new BoilerplateDbContext ( optionsBuilder . Options ) ;
21+ }
22+ }
You can’t perform that action at this time.
0 commit comments