Example #1
0
        ApplicationDbContext IDesignTimeDbContextFactory <ApplicationDbContext> .CreateDbContext(string[] args)
        {
            var optionsBuilder = new DbContextOptionsBuilder <ApplicationDbContext>();
            var dbOptions      = new DatabaseOptions();

            dbOptions.ConnectionString = "Server=(localdb)\\MSSQLLocalDB;Database=websites;Integrated Security=true;AttachDbFileName=C:\\Users\\shide\\source\\repos\\TaskWebsites\\websites.mdf";

            return(new ApplicationDbContext(optionsBuilder.Options, Options.Create <DatabaseOptions>(dbOptions)));
        }
Example #2
0
 public ApplicationDbContext(DbContextOptions <ApplicationDbContext> options, IOptions <DatabaseOptions> config)
     : base(options)
 {
     _configuration = config.Value;
 }