0
0
RhSolutions-Api/RhSolutions.Api/Models/RhsolutionsContext.cs

23 lines
593 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>()
.PrimitiveCollection(e => e.DeprecatedSkus)
.ElementType()
.HasConversion(typeof(SkuConverter));
}
}