Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge branch 'release/9.0-rc1' => 'release/9.0' #34458

Merged
merged 1 commit into from
Aug 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions test/EFCore.Cosmos.FunctionalTests/F1CosmosFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,19 @@ protected override ITestStoreFactory TestStoreFactory
public override TestHelpers TestHelpers
=> CosmosTestHelpers.Instance;

public override async Task ReseedAsync()
protected override async Task<bool> ShouldSeedAsync(F1Context context)
{
await base.ReseedAsync();

using var context = CreateContext();
try
{
await context.Teams.SingleAsync(t => t.Id == Team.Ferrari);
await base.ShouldSeedAsync(context);
}
catch
{
// Recreating the containers without using CosmosClient causes cached metadata in CosmosClient to be out of sync
// and causes the first query to fail. This is a workaround for that.
}

return await base.ShouldSeedAsync(context);
}

public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder)
Expand Down
10 changes: 8 additions & 2 deletions test/EFCore.Specification.Tests/F1FixtureBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder build
.UseModel(CreateModelExternal())
.UseSeeding((c, _) =>
{
if (c.Set<EngineSupplier>().Count() != 0)
if (!ShouldSeed((F1Context)c))
{
return;
}
Expand All @@ -29,7 +29,7 @@ public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder build
})
.UseAsyncSeeding(async (c, _, t) =>
{
if (await c.Set<EngineSupplier>().CountAsync(t) != 0)
if (!await ShouldSeedAsync((F1Context)c))
{
return;
}
Expand All @@ -40,6 +40,12 @@ public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder build
.ConfigureWarnings(
w => w.Ignore(CoreEventId.SaveChangesStarting, CoreEventId.SaveChangesCompleted));

protected virtual bool ShouldSeed(F1Context context)
=> context.EngineSuppliers.Count() == 0;

protected virtual async Task<bool> ShouldSeedAsync(F1Context context)
=> await context.EngineSuppliers.CountAsync() == 0;

protected override IServiceCollection AddServices(IServiceCollection serviceCollection)
=> base.AddServices(serviceCollection.AddSingleton<ISingletonInterceptor, F1MaterializationInterceptor>());

Expand Down