Skip to content
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
18 changes: 17 additions & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -244,11 +244,27 @@
<PackageVersion Update="Microsoft.Extensions.Http" Version="$(MicrosoftExtensionsHttpVersion)" />
<PackageVersion Update="System.Formats.Asn1" Version="$(SystemFormatsAsn1Version)" />
<PackageVersion Update="System.Text.Json" Version="$(SystemTextJsonVersion)" />
<PackageVersion Update="System.Threading.Channels" Version="$(SystemThreadingChannelsVersion)" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net10.0'">
<!-- EF -->
<PackageVersion Update="Microsoft.EntityFrameworkCore.Cosmos" Version="$(MicrosoftEntityFrameworkCoreCosmosPreviewVersion)" />
<PackageVersion Update="Microsoft.EntityFrameworkCore.Design" Version="$(MicrosoftEntityFrameworkCoreDesignPreviewVersion)" />
<PackageVersion Update="Microsoft.EntityFrameworkCore.SqlServer" Version="$(MicrosoftEntityFrameworkCoreSqlServerPreviewVersion)" />
<PackageVersion Update="Microsoft.EntityFrameworkCore.Tools" Version="$(MicrosoftEntityFrameworkCoreToolsPreviewVersion)" />
<PackageVersion Update="Npgsql.EntityFrameworkCore.PostgreSQL" Version="10.0.0-rc.2" />
<!-- ASP.NET Core -->
<PackageVersion Update="Microsoft.AspNetCore.Authentication.Certificate" Version="$(MicrosoftAspNetCoreAuthenticationCertificatePreviewVersion)" />
<PackageVersion Update="Microsoft.AspNetCore.Authentication.JwtBearer" Version="$(MicrosoftAspNetCoreAuthenticationJwtBearerPreviewVersion)" />
<PackageVersion Update="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="$(MicrosoftAspNetCoreAuthenticationOpenIdConnectPreviewVersion)" />
<PackageVersion Update="Microsoft.AspNetCore.OpenApi" Version="$(MicrosoftAspNetCoreOpenApiPreviewVersion)" />
<PackageVersion Update="Microsoft.AspNetCore.OutputCaching.StackExchangeRedis" Version="$(MicrosoftAspNetCoreOutputCachingStackExchangeRedisPreviewVersion)" />
<PackageVersion Update="Microsoft.AspNetCore.TestHost" Version="$(MicrosoftAspNetCoreTestHostPreviewVersion)" />
<PackageVersion Update="Microsoft.Extensions.Caching.Memory" Version="$(MicrosoftExtensionsCachingMemoryPreviewVersion)" />
<PackageVersion Update="Microsoft.Extensions.Caching.StackExchangeRedis" Version="$(MicrosoftExtensionsCachingStackExchangeRedisPreviewVersion)" />
<PackageVersion Update="Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore" Version="$(MicrosoftExtensionsDiagnosticsHealthChecksEntityFrameworkCorePreviewVersion)" />
<PackageVersion Update="Microsoft.Extensions.Diagnostics.HealthChecks" Version="$(MicrosoftExtensionsDiagnosticsHealthChecksPreviewVersion)" />
<PackageVersion Update="Microsoft.Extensions.Features" Version="$(MicrosoftExtensionsFeaturesPreviewVersion)" />
<PackageVersion Update="Microsoft.AspNetCore.SignalR.Client" Version="$(MicrosoftAspNetCoreSignalRClientPreviewVersion)" />
<!-- Runtime -->
<PackageVersion Update="Microsoft.Extensions.Hosting.Abstractions" Version="$(MicrosoftExtensionsHostingAbstractionsPreviewVersion)" />
<PackageVersion Update="Microsoft.Extensions.Hosting" Version="$(MicrosoftExtensionsHostingPreviewVersion)" />
Expand Down
18 changes: 17 additions & 1 deletion eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<VersionPrefix>$(MajorVersion).$(MinorVersion).$(PatchVersion)</VersionPrefix>
<PreReleaseVersionLabel>preview.1</PreReleaseVersionLabel>
<DefaultTargetFramework>net8.0</DefaultTargetFramework>
<AllTargetFrameworks>$(DefaultTargetFramework);net9.0</AllTargetFrameworks>
<AllTargetFrameworks>$(DefaultTargetFramework);net9.0;net10.0</AllTargetFrameworks>
<!-- dotnet versions for running tests -->
<DotNetRuntimePreviousVersionForTesting>8.0.21</DotNetRuntimePreviousVersionForTesting>
<DotNetRuntimeCurrentVersionForTesting>9.0.10</DotNetRuntimeCurrentVersionForTesting>
Expand Down Expand Up @@ -56,11 +56,27 @@
</PropertyGroup>
<!-- .NET 10.0 Package Versions -->
<PropertyGroup Label="Preview">
<!-- EF -->
<MicrosoftEntityFrameworkCoreCosmosPreviewVersion>10.0.0-rc.2.25502.107</MicrosoftEntityFrameworkCoreCosmosPreviewVersion>
<MicrosoftEntityFrameworkCoreDesignPreviewVersion>10.0.0-rc.2.25502.107</MicrosoftEntityFrameworkCoreDesignPreviewVersion>
<MicrosoftEntityFrameworkCoreSqlServerPreviewVersion>10.0.0-rc.2.25502.107</MicrosoftEntityFrameworkCoreSqlServerPreviewVersion>
<MicrosoftEntityFrameworkCoreToolsPreviewVersion>10.0.0-rc.2.25502.107</MicrosoftEntityFrameworkCoreToolsPreviewVersion>
<!-- ASP.NET Core -->
<MicrosoftAspNetCoreAuthenticationCertificatePreviewVersion>10.0.0-rc.2.25502.107</MicrosoftAspNetCoreAuthenticationCertificatePreviewVersion>
<MicrosoftAspNetCoreAuthenticationJwtBearerPreviewVersion>10.0.0-rc.2.25502.107</MicrosoftAspNetCoreAuthenticationJwtBearerPreviewVersion>
<MicrosoftAspNetCoreAuthenticationOpenIdConnectPreviewVersion>10.0.0-rc.2.25502.107</MicrosoftAspNetCoreAuthenticationOpenIdConnectPreviewVersion>
<MicrosoftAspNetCoreOpenApiPreviewVersion>10.0.0-rc.2.25502.107</MicrosoftAspNetCoreOpenApiPreviewVersion>
<MicrosoftAspNetCoreOutputCachingStackExchangeRedisPreviewVersion>10.0.0-rc.2.25502.107</MicrosoftAspNetCoreOutputCachingStackExchangeRedisPreviewVersion>
<MicrosoftAspNetCoreTestHostPreviewVersion>10.0.0-rc.2.25502.107</MicrosoftAspNetCoreTestHostPreviewVersion>
<MicrosoftExtensionsCachingStackExchangeRedisPreviewVersion>10.0.0-rc.2.25502.107</MicrosoftExtensionsCachingStackExchangeRedisPreviewVersion>
<MicrosoftExtensionsDiagnosticsHealthChecksEntityFrameworkCorePreviewVersion>10.0.0-rc.2.25502.107</MicrosoftExtensionsDiagnosticsHealthChecksEntityFrameworkCorePreviewVersion>
<MicrosoftExtensionsDiagnosticsHealthChecksPreviewVersion>10.0.0-rc.2.25502.107</MicrosoftExtensionsDiagnosticsHealthChecksPreviewVersion>
<MicrosoftExtensionsFeaturesPreviewVersion>10.0.0-rc.2.25502.107</MicrosoftExtensionsFeaturesPreviewVersion>
<MicrosoftAspNetCoreSignalRClientPreviewVersion>10.0.0-rc.2.25502.107</MicrosoftAspNetCoreSignalRClientPreviewVersion>
<!-- Runtime -->
<MicrosoftExtensionsHostingAbstractionsPreviewVersion>10.0.0-rc.2.25502.107</MicrosoftExtensionsHostingAbstractionsPreviewVersion>
<MicrosoftExtensionsHostingPreviewVersion>10.0.0-rc.2.25502.107</MicrosoftExtensionsHostingPreviewVersion>
<MicrosoftExtensionsCachingMemoryPreviewVersion>10.0.0-rc.2.25502.107</MicrosoftExtensionsCachingMemoryPreviewVersion>
<MicrosoftExtensionsConfigurationAbstractionsPreviewVersion>10.0.0-rc.2.25502.107</MicrosoftExtensionsConfigurationAbstractionsPreviewVersion>
<MicrosoftExtensionsConfigurationBinderPreviewVersion>10.0.0-rc.2.25502.107</MicrosoftExtensionsConfigurationBinderPreviewVersion>
<MicrosoftExtensionsDependencyInjectionAbstractionsPreviewVersion>10.0.0-rc.2.25502.107</MicrosoftExtensionsDependencyInjectionAbstractionsPreviewVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace Aspire.Microsoft.EntityFrameworkCore.Cosmos.Tests;

public class AspireAzureEfCoreCosmosDBExtensionsTests
{
private const string ConnectionString = "AccountEndpoint=https://fake-account.documents.azure.com:443/;AccountKey=<fake-key>;";
internal const string ConnectionString = "AccountEndpoint=https://fake-account.documents.azure.com:443/;AccountKey=fake;";

[Fact]
public void CanConfigureDbContextOptions()
Expand Down Expand Up @@ -129,7 +129,7 @@ public void RequestTimeoutFromBuilderWinsOverOthers(bool useSettings)
[Fact]
public void CanHave2DbContexts()
{
const string connectionString2 = "AccountEndpoint=https://fake-account2.documents.azure.com:443/;AccountKey=<fake-key2>;";
const string connectionString2 = "AccountEndpoint=https://fake-account2.documents.azure.com:443/;AccountKey=fake;";

var builder = Host.CreateEmptyApplicationBuilder(null);
builder.Configuration.AddInMemoryCollection([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ protected override void PopulateConfiguration(ConfigurationManager configuration
=> configuration.AddInMemoryCollection(new KeyValuePair<string, string?>[]
{
new KeyValuePair<string, string?>("Aspire:Microsoft:EntityFrameworkCore:Cosmos:ConnectionString",
"Host=fake;Database=catalog"),
AspireAzureEfCoreCosmosDBExtensionsTests.ConnectionString),
});

protected override void RegisterComponent(HostApplicationBuilder builder, Action<EntityFrameworkCoreCosmosSettings>? configure = null, string? key = null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace Aspire.Microsoft.EntityFrameworkCore.Cosmos.Tests;

public class EnrichCosmosDbTests : ConformanceTests
{
private const string ConnectionString = "Host=fake;Database=catalog";
private const string ConnectionString = AspireAzureEfCoreCosmosDBExtensionsTests.ConnectionString;
private const string DatabaseName = "TestDatabase";

protected override void RegisterComponent(HostApplicationBuilder builder, Action<EntityFrameworkCoreCosmosSettings>? configure = null, string? key = null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace Aspire.Microsoft.EntityFrameworkCore.SqlServer.Tests;

public class AspireSqlServerEFCoreSqlClientExtensionsTests
{
private const string ConnectionString = "Data Source=fake;Database=master;Encrypt=True";
private const string ConnectionString = "Data Source=fake;Initial Catalog=master;Encrypt=True";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it just nicer or doesn't it work otherwise?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test breaks. EF is changing Database to Initial Catalog somewhere. So I updated these strings to match so the test doesn't break.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AndriySvyryd is that expected?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be some normalizing that SqlClient does. Functionally, there's no difference.


[Fact]
public void ReadsFromConnectionStringsCorrectly()
Expand All @@ -30,7 +30,7 @@ public void ReadsFromConnectionStringsCorrectly()
using var host = builder.Build();
var context = host.Services.GetRequiredService<TestDbContext>();

Assert.Equal(ConnectionString, context.Database.GetDbConnection().ConnectionString);
AssertCorrectConnectionString(ConnectionString, context.Database.GetDbConnection().ConnectionString);
}

[Fact]
Expand All @@ -47,7 +47,7 @@ public void ConnectionStringCanBeSetInCode()
var context = host.Services.GetRequiredService<TestDbContext>();

var actualConnectionString = context.Database.GetDbConnection().ConnectionString;
Assert.Equal(ConnectionString, actualConnectionString);
AssertCorrectConnectionString(ConnectionString, actualConnectionString);
// the connection string from config should not be used since code set it explicitly
Assert.DoesNotContain("unused", actualConnectionString);
}
Expand All @@ -67,7 +67,7 @@ public void ConnectionNameWinsOverConfigSection()
var context = host.Services.GetRequiredService<TestDbContext>();

var actualConnectionString = context.Database.GetDbConnection().ConnectionString;
Assert.Equal(ConnectionString, actualConnectionString);
AssertCorrectConnectionString(ConnectionString, actualConnectionString);
// the connection string from config should not be used since it was found in ConnectionStrings
Assert.DoesNotContain("unused", actualConnectionString);
}
Expand Down Expand Up @@ -103,7 +103,7 @@ public void CanConfigureDbContextOptions()

// ensure the connection string from config was respected
var actualConnectionString = context.Database.GetDbConnection().ConnectionString;
Assert.Equal(ConnectionString, actualConnectionString);
AssertCorrectConnectionString(ConnectionString, actualConnectionString);

// ensure the retry strategy is enabled and set to its default value
Assert.NotNull(extension.ExecutionStrategyFactory);
Expand Down Expand Up @@ -147,7 +147,7 @@ public void CanConfigureDbContextOptionsWithoutRetry()

// ensure the connection string from config was respected
var actualConnectionString = context.Database.GetDbConnection().ConnectionString;
Assert.Equal(ConnectionString, actualConnectionString);
AssertCorrectConnectionString(ConnectionString, actualConnectionString);

// ensure no retry strategy was registered
Assert.Null(extension.ExecutionStrategyFactory);
Expand Down Expand Up @@ -230,7 +230,7 @@ public void CommandTimeoutFromBuilderWinsOverOthers(bool useSettings)
[Fact]
public void CanHave2DbContexts()
{
const string connectionString2 = "Data Source=fake2;Database=master2;Encrypt=True";
const string connectionString2 = "Data Source=fake2;Initial Catalog=master2;Encrypt=True";

var builder = Host.CreateEmptyApplicationBuilder(null);
builder.Configuration.AddInMemoryCollection([
Expand All @@ -246,10 +246,10 @@ public void CanHave2DbContexts()
var context2 = host.Services.GetRequiredService<TestDbContext2>();

var actualConnectionString = context.Database.GetDbConnection().ConnectionString;
Assert.Equal(ConnectionString, actualConnectionString);
AssertCorrectConnectionString(ConnectionString, actualConnectionString);

actualConnectionString = context2.Database.GetDbConnection().ConnectionString;
Assert.Equal(connectionString2, actualConnectionString);
AssertCorrectConnectionString(connectionString2, actualConnectionString);
}

[Theory]
Expand Down Expand Up @@ -351,6 +351,16 @@ public void AddSqlServerDbContext_WithConnectionSpecificAndContextSpecificSettin
Assert.Equal(120, capturedSettings.CommandTimeout);
}

private static void AssertCorrectConnectionString(string expectedConnectionString, string actualConnectionString)
{
#if NET10_0_OR_GREATER
// In .NET 10, the connection string may have additional parameters appended, so we check the start only.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In .NET 10 or in EF 10. nit but just want to be sure what changed, not asking for changing the comment

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EF changed, as far as I can tell. It started adding the app name to the connection string. I think dotnet/efcore#36548 caused it.

Assert.StartsWith(expectedConnectionString, actualConnectionString);
#else
Assert.Equal(expectedConnectionString, actualConnectionString);
#endif
}

public class TestDbContext2 : DbContext
{
public TestDbContext2(DbContextOptions<TestDbContext2> options) : base(options)
Expand Down