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

23 lines
593 B
C#
Raw Normal View History

2022-12-14 09:53:10 +03:00
using Microsoft.EntityFrameworkCore;
2023-05-11 07:55:26 +03:00
namespace RhSolutions.Models;
2022-12-14 09:53:10 +03:00
public class RhSolutionsContext : DbContext
{
public RhSolutionsContext(DbContextOptions<RhSolutionsContext> options)
2023-05-11 07:55:26 +03:00
: base(options) { }
2022-12-14 09:53:10 +03:00
public DbSet<Product> Products => Set<Product>();
2023-05-11 07:55:26 +03:00
protected override void OnModelCreating(ModelBuilder builder)
{
builder.Entity<Product>()
.Property(e => e.ProductSku)
.HasConversion(v => v.ToString(), v => new ProductSku(v));
2024-01-12 15:22:43 +03:00
builder.Entity<Product>()
.PrimitiveCollection(e => e.DeprecatedSkus)
.ElementType()
.HasConversion(typeof(SkuConverter));
2023-05-11 07:55:26 +03:00
}
2022-12-14 09:53:10 +03:00
}