22 lines
618 B
C#
22 lines
618 B
C#
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace RhSolutions.Models;
|
|
|
|
public class RhSolutionsContext : DbContext
|
|
{
|
|
public RhSolutionsContext(DbContextOptions<RhSolutionsContext> options)
|
|
: base(options) { }
|
|
|
|
public DbSet<Product> Products => Set<Product>();
|
|
|
|
protected override void OnModelCreating(ModelBuilder builder)
|
|
{
|
|
builder.Entity<Product>()
|
|
.Property(e => e.ProductSku)
|
|
.HasConversion(v => v.ToString(), v => new ProductSku(v));
|
|
builder.Entity<Product>()
|
|
.Property(e => e.DeprecatedSkus)
|
|
.HasPostgresArrayConversion<ProductSku, string>(v => v.ToString(), v => new ProductSku(v));
|
|
}
|
|
}
|