0
0
RhSolutions-Api/RhSolutions.Api/Models/RhsolutionsContext.cs
2024-01-23 23:30:47 +03:00

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");
}
}