23 lines
942 B
C#
23 lines
942 B
C#
using Bimix.Domain.Entities;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace Bimix.Infrastructure.Data;
|
|
|
|
public class BimixDbContext(DbContextOptions<BimixDbContext> options) : DbContext(options)
|
|
{
|
|
public DbSet<Product> Products { get; set; }
|
|
public DbSet<SyncState> SyncStates { get; set; }
|
|
|
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
{
|
|
base.OnModelCreating(modelBuilder);
|
|
|
|
modelBuilder.Entity<Product>().HasKey(x => x.Id);
|
|
modelBuilder.Entity<Product>().Property(x => x.Name).IsRequired().HasMaxLength(512);
|
|
modelBuilder.Entity<Product>().Property(x => x.Code).IsRequired().HasMaxLength(40);
|
|
modelBuilder.Entity<Product>().Property(x => x.Ean).IsRequired().HasMaxLength(50);
|
|
modelBuilder.Entity<Product>().Property(x => x.StockAddresses).IsRequired().HasMaxLength(512);
|
|
|
|
modelBuilder.Entity<SyncState>().HasKey((x => x.Entity));
|
|
}
|
|
} |