You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
iot/labs/CameraCard/CameraCard/Data/MyDbContext.cs

28 lines
746 B

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" });
}
}
}