Skip to content

Instantly share code, notes, and snippets.

@ivanvs
Created January 14, 2019 21:48
Show Gist options
  • Select an option

  • Save ivanvs/80d8e4c178387128a0188058ce8856e6 to your computer and use it in GitHub Desktop.

Select an option

Save ivanvs/80d8e4c178387128a0188058ce8856e6 to your computer and use it in GitHub Desktop.
Fix problem with connection to database
public class InitializeWithDefaultData : DropCreateDatabaseAlways<AuthContext>
{
protected override void Seed(AuthContext context)
{
using (var store = new RoleStore<IdentityRole>(context))
{
using (var manager = new RoleManager<IdentityRole>(store))
{
manager.Create(new IdentityRole("admin"));
manager.Create(new IdentityRole("student"));
manager.Create(new IdentityRole("parent"));
manager.Create(new IdentityRole("teacher"));
}
}
using (var userStore = new UserStore<ApplicationUser>(context))
{
using (var userManager = new UserManager<ApplicationUser>(userStore))
{
ApplicationUser student = new Student();
student.Email = "[email protected]";
student.UserName = "[email protected]";
student.FirstName = "Ivan";
student.LastName = "Vasiljevic";
userManager.Create(student, "1Admin!");
userManager.AddToRole(student.Id, "userStudent");
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment