This commit is contained in:
21
Helpers/AppDbContext.cs
Normal file
21
Helpers/AppDbContext.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
public class AppDbContext : DbContext
|
||||
{
|
||||
public DbSet<BubblePointEntity> BubblePointRecords { get; set; }
|
||||
public DbSet<PoreDistributionEntity> PoreDistributionRecords { get; set; }
|
||||
public DbSet<DataPointEntity> DataPoints { get; set; }
|
||||
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder options)
|
||||
=> options.UseSqlite("Data Source=membrane_test.db");
|
||||
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.Entity<PoreDistributionEntity>()
|
||||
.HasMany(p => p.DataPoints)
|
||||
.WithOne(d => d.PoreDistribution)
|
||||
.HasForeignKey(d => d.PoreDistributionId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user