public static void Initialize(IServiceProvider serviceProvider) { using (var context = new OTPContext( serviceProvider.GetRequiredService <DbContextOptions <OTPContext> >())) { //Adding seed data if (context.Users.Any()) { return; // Data was already seeded } context.Users.AddRange( new User { UserID = "122212MA" }, new User { UserID = "122123MI" } ); context.SaveChanges(); } }
public IActionResult Register(UserRegister model, string returnUrl = null) { if (!ModelState.IsValid) { return(View(model)); } var user = new User { Id = Guid.NewGuid(), UserName = model.UserName, CompleteName = model.CompleteName, Password = model.Password, Email = model.Email, }; using (var context = new OTPContext()) { context.Users.Add(user); context.SaveChanges(); } return(RedirectToAction("Login", "Account")); }