using Microsoft.EntityFrameworkCore;
using Microsoft.Data.Sqlite;
public UserEntity(string name, string password) {
Salt = Guid.NewGuid().ToString();
public Guid Id { get; set; }
public string Name { get; set; }
public string Password { get; set; }
public string Salt { get; set; }
public class MyDbContext:DbContext
public MyDbContext(DbContextOptions<MyDbContext> options)
Database.EnsureCreated();
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
protected override void OnModelCreating(ModelBuilder modelBuilder)
public DbSet<UserEntity> User { get; set; }
public static void Main()
var connection = new SqliteConnection("DataSource=:memory:");
var options = new DbContextOptionsBuilder<MyDbContext>()
using (var context = new MyDbContext(options))
var admin = new UserEntity("admin", "admin123");
Console.WriteLine(JsonSerializer.Serialize(admin));
using (var context = new MyDbContext(options))
var user = context.User.FirstOrDefault();
Console.WriteLine(user == null ? "" : JsonSerializer.Serialize(user));