-
Notifications
You must be signed in to change notification settings - Fork 837
Target net10.0 in client integrations #12500
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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"; | ||
|
|
||
| [Fact] | ||
| public void ReadsFromConnectionStringsCorrectly() | ||
|
|
@@ -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] | ||
|
|
@@ -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); | ||
| } | ||
|
|
@@ -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); | ||
| } | ||
|
|
@@ -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); | ||
|
|
@@ -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); | ||
|
|
@@ -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([ | ||
|
|
@@ -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] | ||
|
|
@@ -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. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) | ||
|
|
||
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
DatabasetoInitial Catalogsomewhere. So I updated these strings to match so the test doesn't break.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AndriySvyryd is that expected?
There was a problem hiding this comment.
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.