29 lines
972 B
C#
29 lines
972 B
C#
|
using System.ComponentModel.DataAnnotations;
|
||
|
using Microsoft.EntityFrameworkCore;
|
||
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||
|
|
||
|
namespace labdb.Models;
|
||
|
|
||
|
public record TestId : EntityIdBase<TestId>;
|
||
|
|
||
|
public class Test : EntityBase<TestId>
|
||
|
{
|
||
|
public string Name { get; set; } = null!;
|
||
|
public string? Abbreviation { get; set; }
|
||
|
public string? Description { get; set; }
|
||
|
public string? PubchemLink { get; set; }
|
||
|
|
||
|
}
|
||
|
|
||
|
public class TestConfiguration : EntityBaseConfiguration<Test, TestId>
|
||
|
{
|
||
|
public override void Configure(EntityTypeBuilder<Test> builder)
|
||
|
{
|
||
|
base.Configure(builder);
|
||
|
|
||
|
builder.HasIndex(x => x.Name, "name").IsUnique();
|
||
|
builder.HasIndex(x => x.Name, "name_trgm").HasMethod("gin").HasOperators("gin_trgm_ops");
|
||
|
builder.HasIndex(x => x.Abbreviation, "abbreviation").IsUnique();
|
||
|
builder.HasIndex(x => x.Abbreviation, "abbreviation_trgm").HasMethod("gin").HasOperators("gin_trgm_ops");
|
||
|
}
|
||
|
}
|