public static void Initialize(IServiceProvider serviceProvider) { using (var context = new MSAContext( serviceProvider.GetRequiredService < DbContextOptions <MSAContext> >())) { if (context.User.Any()) { return; // DB has been seeded } var users = UserGenerator.GenerateUsers(); foreach (User user in users) { context.User.AddRange(user); } Console.WriteLine("DB seeded."); context.SaveChanges(); } }
public UserRepository(MSAContext dbContext) { model = dbContext.User; tableName = "User"; context = dbContext; }
public FriendshipRepository(MSAContext dbContext) { model = dbContext.Friendship; tableName = "Friendship"; context = dbContext; }
public MessageRepository(MSAContext dbContext) { model = dbContext.Message; tableName = "Message"; context = dbContext; }
public ConversationRepository(MSAContext dbContext) { model = dbContext.Conversation; tableName = "Conversation"; context = dbContext; }
public CommentRepository(MSAContext dbContext) { model = dbContext.Comment; tableName = "Comment"; context = dbContext; }