Last active
November 28, 2020 21:45
-
-
Save AbubakarSiddiq/95e94b1670234bb6a73fc2255b2bd791 to your computer and use it in GitHub Desktop.
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
using Microsoft.AspNetCore.Identity; | |
using Microsoft.Extensions.DependencyInjection; | |
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Threading.Tasks; | |
namespace BookStore.Data | |
{ | |
public class SeedDB | |
{ | |
public static void Initialize(IServiceProvider serviceProvider) | |
{ | |
var context = serviceProvider.GetRequiredService<BookStoreDbContext>(); | |
var userManager = serviceProvider.GetRequiredService<UserManager<ApplicationUser>>(); | |
context.Database.EnsureCreated(); | |
if (!context.Users.Any()) | |
{ | |
ApplicationUser user = new ApplicationUser() | |
{ | |
Email = "[email protected]", | |
UserName = "test", | |
SecurityStamp = Guid.NewGuid().ToString() | |
}; | |
userManager.CreateAsync(user, "Test@123"); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment