|
|
|
@ -0,0 +1,28 @@
|
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
|
|
|
|
|
|
namespace CameraCard.Data
|
|
|
|
|
{
|
|
|
|
|
public class MyDbContext : DbContext
|
|
|
|
|
{
|
|
|
|
|
public DbSet<User> Users { get; set; }
|
|
|
|
|
public DbSet<Student> Students { get; set; }
|
|
|
|
|
|
|
|
|
|
protected override void OnConfiguring(DbContextOptionsBuilder options) => options.UseSqlite("Data Source=data.db;Password=123456;");
|
|
|
|
|
|
|
|
|
|
public static void Init()
|
|
|
|
|
{
|
|
|
|
|
using (var db = new MyDbContext())
|
|
|
|
|
{
|
|
|
|
|
if (db.Database.EnsureCreated())
|
|
|
|
|
{
|
|
|
|
|
db.Seed();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Seed()
|
|
|
|
|
{
|
|
|
|
|
this.Users.Add(new User { UserName = "admin", PasswordHash = "123456" });
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|