blob: 88b1585106720c2c0a87c1addd6c0ae130a59fe8 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;
namespace Dough.Models.Database
{
public class MainDbContext : DbContext
{
public MainDbContext(DbContextOptions<MainDbContext> options) : base(options) {
}
public DbSet<Transaction> Transactions { get; set; }
public DbSet<User> Users { get; set; }
public DbSet<Category> Categories { get; set; }
public DbSet<Payee> Payees { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Transaction>().ToTable("Transactions");
var initUser = new User("ivar");
initUser.SetBaseProperties();
initUser.HashAndSetPassword("ivar123");
modelBuilder.Entity<User>().HasData(new List<User>
{
initUser
});
modelBuilder.Entity<User>().ToTable("Users");
modelBuilder.Entity<Category>().ToTable("Categories");
modelBuilder.Entity<Payee>().ToTable("Payees");
base.OnModelCreating(modelBuilder);
}
}
}
|