27 lines
719 B
C#
27 lines
719 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));
|
|
builder.Entity<Product>()
|
|
.HasIndex(b => new { b.Name })
|
|
.HasMethod("GIN")
|
|
.IsTsVectorExpressionIndex("russian");
|
|
}
|
|
}
|