public static void Initialize(IServiceProvider serviceProvider) { using var ctx = new OctoCodesContext(serviceProvider.GetRequiredService <DbContextOptions <OctoCodesContext> >()); if (ctx.Users.Any()) { return; } ctx.Users.Add( new User { Username = "******", Password = AdminController.EncryptPassword("Password1") } ); ctx.SaveChanges(); }
public ArticleController(OctoCodesContext ctx) { this.ctx = ctx; }
public AdminController(OctoCodesContext ctx, IWebHostEnvironment webHostEnvironment) { this.ctx = ctx; this.webHostEnvironment = webHostEnvironment; }