Created
January 14, 2019 21:48
-
-
Save ivanvs/80d8e4c178387128a0188058ce8856e6 to your computer and use it in GitHub Desktop.
Fix problem with connection to database
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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