Refactor: the project is now divided into a more clear structure, with **Infrastructure** and **Application** layers added. Refactor: configurations are split into sections for different layers. Fix: now EF Core related operations, such as migration, should be invoked in `OptixServe.Infrastructure`, with config file and data dir passed into `dotnet ef` command. See `OptixServe.Infrastructure/Utilites/DesignTimeDbContextFactory.cs` for details. Fix: EF migrations are ignored in gitignore on purpose in early development.
22 lines
557 B
C#
22 lines
557 B
C#
using Microsoft.EntityFrameworkCore;
|
|
using OptixServe.Core.Models;
|
|
|
|
namespace OptixServe.Infrastructure.Data;
|
|
|
|
public class AppDbContext(DbContextOptions options) : DbContext(options)
|
|
{
|
|
public DbSet<User> Users { get; set; } = null!;
|
|
|
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
{
|
|
modelBuilder.Entity<User>(user =>
|
|
{
|
|
user.HasKey(u => u.Id);
|
|
});
|
|
|
|
modelBuilder.Entity<User>().HasData([
|
|
new() {Id = "1", UserName = "admin", Password = "admin12345"}
|
|
]);
|
|
}
|
|
}
|