2025-06-19 21:50:35 +02:00
|
|
|
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; }
|
2025-06-23 21:52:09 +02:00
|
|
|
public DbSet<SyncState> SyncStates { get; set; }
|
2025-06-19 21:50:35 +02:00
|
|
|
|
|
|
|
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
|
|
|
{
|
|
|
|
|
base.OnModelCreating(modelBuilder);
|
|
|
|
|
|
2025-06-23 21:52:09 +02:00
|
|
|
modelBuilder.Entity<Product>().HasKey(x => x.Id);
|
|
|
|
|
modelBuilder.Entity<Product>().Property(x => x.Name).IsRequired().HasMaxLength(512);
|
2025-06-28 18:54:08 +01:00
|
|
|
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);
|
2025-06-23 21:52:09 +02:00
|
|
|
|
|
|
|
|
modelBuilder.Entity<SyncState>().HasKey((x => x.Entity));
|
2025-06-19 21:50:35 +02:00
|
|
|
}
|
|
|
|
|
}
|