예제 #1
0
        public FamilyGuyDbContext CreateDbContext(string[] args)
        {
            DbContextOptionsBuilder <FamilyGuyDbContext> optionsBuilder = new DbContextOptionsBuilder <FamilyGuyDbContext>();

            SqlSettings sqlSettings = new SqlSettings();

            new ConfigurationBuilder()
            .SetBasePath(AppContext.BaseDirectory)
            .AddJsonFile(GetAppSettingsFileName())
            .AddEnvironmentVariables()
            .Build()
            .GetSection("Sql")
            .Bind(sqlSettings);

            optionsBuilder.UseSqlServer(sqlSettings.ConnectionString);
            return(new FamilyGuyDbContext(optionsBuilder.Options, sqlSettings));
        }
예제 #2
0
 public FamilyGuyDbContext(DbContextOptions <FamilyGuyDbContext> options, SqlSettings settings) : base(options)
 {
     _settings = settings;
 }