Open AnikeRU opened 1 year ago
Thanks, would you care to share it as a PR?
Yes, you can use this code in a blazorboilerplate project. New content of the LocalizationDbContext.cs:
` using BlazorBoilerplate.Infrastructure.Storage.DataModels; using Microsoft.EntityFrameworkCore;
namespace BlazorBoilerplate.Storage
{
public class LocalizationDbContext : DbContext
{
public LocalizationDbContext(DbContextOptions
public DbSet<PluralFormRule> PluralFormRules { get; set; }
public DbSet<PluralTranslation> PluralTranslations { get; set; }
public DbSet<LocalizationRecord> LocalizationRecords { get; set; }
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
builder.Entity<LocalizationRecord>().HasIndex(c => new { c.MsgId, c.Culture, c.ContextId }).IsUnique();
builder.Entity<PluralTranslation>().HasIndex(e => new { e.LocalizationRecordId, e.Index }, "IX_LOCRECID_INDEX").IsUnique();
}
}
}`
Hello
To avoid this error in Postgres add unique index to the table PluralTranslation in LocalizationDbContext.cs:
builder.Entity().HasIndex(e => new { e.LocalizationRecordId, e.Index }, "IX_LOCRECID_INDEX").IsUnique();
Else this row will be generate error 42P10 :
localization DbContext.Plural Translations.UpsertRange(plural Translations).On(l => new { l.Localization RecordId, l.Index }).RunAsync();