Förberett för övergång till entity framework

This commit is contained in:
2025-09-01 11:14:38 +02:00
parent eb9ea77dd9
commit b04fc7e06e
13 changed files with 191 additions and 73 deletions

View File

@ -0,0 +1,25 @@
using GreadyPoang.EntityLayer;
using Microsoft.EntityFrameworkCore;
namespace GreadyPoang.DataLayer.Database
{
public class DataContext : DbContext
{
public DataContext(DbContextOptions<DataContext> options) : base(options)
{
}
//public DbSet<User> Users => Set<User>();
public DbSet<Participant> Participants { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<Participant>().HasData(
new Participant { ParticipantId = 1, FirstName = "John", LastName = "Doe", Email = "John.Doe@gmail.com" },
new Participant { ParticipantId = 2, FirstName = "Jane", LastName = "Black", Email = "jb@gmail.com" },
new Participant { ParticipantId = 3, FirstName = "Mary", LastName = "White", Email = "mw@gmail.com" }
);
}
}
}