Query
public async Task GetByIdAsync(UnitId id, CancellationToken cancellationToken = default)
{
return await _dbContext.Units
.FirstOrDefaultAsync(unit => unit.Id == id, cancellationToken);
}
На этом объекте
using Server.Domain.Units;
using Finbuckle.MultiTenant.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Server.Infrastructure.Configurations;
internal class UnitConfiguration : IEntityTypeConfiguration
{
public void Configure(EntityTypeBuilder builder)
{
builder.ToTable("lookup_units");
builder.HasKey(u => u.Id);
builder.Property(u => u.Id)
.ValueGeneratedNever()
.HasConversion(
id => id.Value,
value => UnitId.Create(value));
builder.HasIndex(u => u.Name).IsUnique();
builder.HasQueryFilter(q => !q.IsDeleted);
builder.IsMultiTenant().AdjustUniqueIndexes();
builder.Property(u => u.Name).HasMaxLength(64);
builder.Property(u => u.DefaultContentCount);
builder.HasData(new List()
{
Unit.Create(
UnitId.Create(Guid.Parse("F7AE4D5C-B1B7-47F0-B0A0-D98DAC374FE8")),
"bag", null, "tenant-1")
});
}
}
Обстоятельства:
- Только когда IsMultiTenant вызывается в следующем объекте
Только когда я выполняю интеграционный тест с использованием WebApplicationFactory
Чтобы свести к минимуму зависимости и изолировать проблему, я настроил MultiTenant следующим образом:
services.AddMultiTenant()
.WithStaticStrategy("tenant-1")
.WithInMemoryStore(config=>
config.Tenants.Add(new TenantInfo
{
Id = "tenant-1",Identifier = "tenant-1", Name = "tenant-1",
}))
;
Подробнее здесь: https://stackoverflow.com/questions/782 ... -webapplic