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.
48 lines
1.3 KiB
48 lines
1.3 KiB
using Infrastructure.Entities;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace Infrastructure;
|
|
|
|
public class AlumniDbContext : DbContext
|
|
{
|
|
public virtual DbSet<User> Alumni { get; set; }
|
|
public virtual DbSet<ExperienceEntity> Experiences { get; set; }
|
|
public virtual DbSet<FormationEntity> Formations { get; set; }
|
|
public virtual DbSet<EventEntity> Events { get; set; }
|
|
public AlumniDbContext()
|
|
{
|
|
}
|
|
public AlumniDbContext(DbContextOptions<AlumniDbContext> options)
|
|
: base(options)
|
|
{
|
|
}
|
|
|
|
protected override void OnConfiguring(DbContextOptionsBuilder options)
|
|
{
|
|
if (!options.IsConfigured)
|
|
{
|
|
options.UseSqlite("Data Source=FirstTest.db");
|
|
}
|
|
}
|
|
|
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
{
|
|
modelBuilder.Entity<EventEntity>().Property(e => e.Title)
|
|
.IsRequired();
|
|
|
|
modelBuilder.Entity<User>().Property(a => a.FirstName)
|
|
.IsRequired();
|
|
|
|
modelBuilder.Entity<User>().Property(a => a.Email)
|
|
.IsRequired();
|
|
|
|
modelBuilder.Entity<ExperienceEntity>()
|
|
.Property(e => e.Title)
|
|
.IsRequired();
|
|
|
|
modelBuilder.Entity<FormationEntity>().Property(f => f.Name)
|
|
.IsRequired();
|
|
|
|
base.OnModelCreating(modelBuilder);
|
|
}
|
|
} |