Initial commit
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace RobotNet10.RobotApp.Data
|
||||
{
|
||||
public class ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : IdentityDbContext<ApplicationUser>(options)
|
||||
{
|
||||
public DbSet<RobotConfig> RobotConfigs { get; private set; }
|
||||
public DbSet<RobotSimulationConfig> RobotSimulationConfigs { get; private set; }
|
||||
public DbSet<RobotPlcConfig> RobotPlcConfigs { get; private set; }
|
||||
public DbSet<RobotVDA5050Config> RobotVDA5050Configs { get; private set; }
|
||||
public DbSet<RobotSafetyConfig> RobotSafetyConfigs { get; private set; }
|
||||
public DbSet<DockStationConfig> DockStationConfigs { get; private set; }
|
||||
public DbSet<DockStationMarkerEntry> DockStationMarkerEntries { get; private set; }
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
base.OnModelCreating(modelBuilder);
|
||||
|
||||
modelBuilder.Entity<DockStationConfig>()
|
||||
.HasIndex(d => d.StationId)
|
||||
.IsUnique();
|
||||
|
||||
modelBuilder.Entity<DockStationConfig>()
|
||||
.HasMany(d => d.MarkerEntries)
|
||||
.WithOne(m => m.DockStationConfig)
|
||||
.HasForeignKey(m => m.DockStationConfigId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user