diff --git a/entity-framework/core/what-is-new/ef-core-9.0/whatsnew.md b/entity-framework/core/what-is-new/ef-core-9.0/whatsnew.md index 0091fd8bc6..dcc6d1d574 100644 --- a/entity-framework/core/what-is-new/ef-core-9.0/whatsnew.md +++ b/entity-framework/core/what-is-new/ef-core-9.0/whatsnew.md @@ -2,7 +2,7 @@ title: What's New in EF Core 9 description: Overview of new features in EF Core 9 author: ajcvickers -ms.date: 03/07/2024 +ms.date: 05/02/2024 uid: core/what-is-new/ef-core-9.0/whatsnew --- @@ -15,15 +15,113 @@ EF9 is available as [daily builds](https://github.com/dotnet/efcore/blob/main/do > [!TIP] > You can run and debug into the samples by [downloading the sample code from GitHub](https://github.com/dotnet/EntityFramework.Docs). Each section below links to the source code specific to that section. -EF9 targets .NET 8, and can therefore be used with either [.NET 8 (LTS)](https://dotnet.microsoft.com/download/dotnet/8.0) or a .NET 9 preview. +EF9 targets .NET 8, and can therefore be used with either [.NET 8 (LTS)](https://dotnet.microsoft.com/download/dotnet/8.0) or a [.NET 9 preview](https://dotnet.microsoft.com/download/dotnet/9.0). > [!TIP] > The _What's New_ docs are updated for each preview. All the samples are set up to use the [EF9 daily builds](https://github.com/dotnet/efcore/blob/main/docs/DailyBuilds.md), which usually have several additional weeks of completed work compared to the latest preview. We strongly encourage use of the daily builds when testing new features so that you're not doing your testing against stale bits. + + +## Azure Cosmos DB for NoSQL + +We are working on significant updates in EF9 to the EF Core database provider for Azure Cosmos DB for NoSQL. + +### Role-based access + +Azure Cosmos DB for NoSQL includes a [built-in role-based access control (RBAC) system](/azure/cosmos-db/role-based-access-control). This is now supported by EF9 for both management and use of containers. No changes are required to application code. See [Issue #32197](https://github.com/dotnet/efcore/issues/32197) for more information. + +### Synchronous access blocked by default + +> [!TIP] +> The code shown here comes from [CosmosSyncApisSample.cs](https://github.com/dotnet/EntityFramework.Docs/tree/main/samples/core/Miscellaneous/NewInEFCore9.Cosmos/CosmosSyncApisSample.cs). + +Azure Cosmos DB for NoSQL does not support synchronous (blocking) access from application code. Previously, EF masked this by default by blocking for you on async calls. However, this both encourages sync use, which is bad practice, and [may cause deadlocks](https://blog.stephencleary.com/2012/07/dont-block-on-async-code.html). Therefore, starting with EF9, an exception is thrown when synchronous access is attempted. For example: + +```output +System.InvalidOperationException: An error was generated for warning 'Microsoft.EntityFrameworkCore.Database.SyncNotSupported': + Azure Cosmos DB does not support synchronous I/O. Make sure to use and correctly await only async methods when using + Entity Framework Core to access Azure Cosmos DB. See https://aka.ms/ef-cosmos-nosync for more information. + This exception can be suppressed or logged by passing event ID 'CosmosEventId.SyncNotSupported' to the 'ConfigureWarnings' + method in 'DbContext.OnConfiguring' or 'AddDbContext'. + at Microsoft.EntityFrameworkCore.Diagnostics.EventDefinition.Log[TLoggerCategory](IDiagnosticsLogger`1 logger, Exception exception) + at Microsoft.EntityFrameworkCore.Cosmos.Diagnostics.Internal.CosmosLoggerExtensions.SyncNotSupported(IDiagnosticsLogger`1 diagnostics) + at Microsoft.EntityFrameworkCore.Cosmos.Storage.Internal.CosmosClientWrapper.DeleteDatabase() + at Microsoft.EntityFrameworkCore.Cosmos.Storage.Internal.CosmosDatabaseCreator.EnsureDeleted() + at Microsoft.EntityFrameworkCore.Infrastructure.DatabaseFacade.EnsureDeleted() +``` + +As the exception says, sync access can still be used for now by configuring the warning level appropriately. For example, in `OnConfiguring` on your `DbContext` type: + +```csharp +protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) + => optionsBuilder.ConfigureWarnings(b => b.Ignore(CosmosEventId.SyncNotSupported)); +``` + +Note, however, that we plan to fully remove sync support in EF11, so start updating to use async methods like `ToListAsync` and `SaveChangesAsync` as soon as possible! + +### Enhanced primitive collections + +> [!TIP] +> The code shown here comes from [CosmosPrimitiveTypesSample.cs](https://github.com/dotnet/EntityFramework.Docs/tree/main/samples/core/Miscellaneous/NewInEFCore9.Cosmos/CosmosPrimitiveTypesSample.cs). + +The Cosmos DB provider has supported primitive collections in a limited form since EF Core 6. This is support is being enhanced in EF9, starting with consolidation of the metadata and API surfaces for primitive collections in document databases to align with primitive collections in relational databases. This means that primitive collections can now be explicitly mapped using the model building API, allowing for facets of the element type to be configured. For example, to map a list of required (i.e. non-null) strings: + + +[!code-csharp[ConfigureCollection](../../../../samples/core/Miscellaneous/NewInEFCore9.Cosmos/CosmosPrimitiveTypesSample.cs?name=ConfigureCollection)] + +See [What's new in EF8: primitive collections](xref:core/what-is-new/ef-core-8.0/whatsnew#primitive-collections) for more information on the model building API. + +## AOT and pre-compiled queries + +As mentioned in the introduction, there is a lot of work going on behind the scenes to allow EF Core to run without just-in-time (JIT) compilation. Instead, EF compile ahead-of-time (AOT) everything needed to run queries in the application. This AOT compilation and related processing will happen as part of building and publishing the application. At this point in the EF9 release, there is not much available that can be used by you, the app developer. However, for those interested, the completed issues in EF9 that support AOT and pre-compiled queries are: + +- [Compiled model: Use static binding instead of reflection for properties and fields](https://github.com/dotnet/efcore/issues/24900) +- [Compiled model: Generate lambdas used in change tracking](https://github.com/dotnet/efcore/issues/24904) +- [Make change tracking and the update pipeline compatible with AOT/trimming](https://github.com/dotnet/efcore/issues/29761) +- [Use interceptors to redirect the query to precompiled code](https://github.com/dotnet/efcore/issues/31331) +- [Make all SQL expression nodes quotable](https://github.com/dotnet/efcore/issues/33008) +- [Generate the compiled model during build](https://github.com/dotnet/efcore/issues/24894) +- [Discover the compiled model automatically](https://github.com/dotnet/efcore/issues/24893) +- [Make ParameterExtractingExpressionVisitor capable of extracting paths to evaluatable fragments in the tree](https://github.com/dotnet/efcore/issues/32999) +- [Generate expression trees in compiled models (query filters, value converters)](https://github.com/dotnet/efcore/issues/29924) +- [Make LinqToCSharpSyntaxTranslator more resilient to multiple declaration of the same variable in nested scopes](https://github.com/dotnet/efcore/issues/32716) +- [Optimize ParameterExtractingExpressionVisitor](https://github.com/dotnet/efcore/issues/32698) + +Check back here for examples of how to use pre-compiled queries as the experience comes together. + ## LINQ and SQL translation The team is working on some significant architecture changes to the query pipeline in EF Core 9 as part of our continued improvements to JSON mapping and document databases. This means we need to get **people like you** to run your code on these new internals. (If you're reading a "What's New" doc at this point in the release, then you're a really engaged part of the community; thank you!) We have over 120,000 tests, but it's not enough! We need you, people running real code on our bits, in order to find issues and ship a solid release! + + +### GroupBy complex types + +> [!TIP] +> The code shown here comes from [ComplexTypesSample.cs](https://github.com/dotnet/EntityFramework.Docs/tree/main/samples/core/Miscellaneous/NewInEFCore9/ComplexTypesSample.cs). + +EF9 supports grouping by a complex type instance. For example: + + +[!code-csharp[GroupByComplexType](../../../../samples/core/Miscellaneous/NewInEFCore9/ComplexTypesSample.cs?name=GroupByComplexType)] + +EF translates this as grouping by each member of the complex type, which aligns with the semantics of complex types as value objects. For example, on Azure SQL: + +```sql +SELECT [s].[StoreAddress_City], [s].[StoreAddress_Country], [s].[StoreAddress_Line1], [s].[StoreAddress_Line2], [s].[StoreAddress_PostCode], COUNT(*) AS [Count] +FROM [Stores] AS [s] +GROUP BY [s].[StoreAddress_City], [s].[StoreAddress_Country], [s].[StoreAddress_Line1], [s].[StoreAddress_Line2], [s].[StoreAddress_PostCode] +``` + ### Prune columns passed to OPENJSON's WITH clause @@ -680,6 +778,66 @@ Now, whenever the model changes, the compiled model will be automatically rebuil > [NOTE!] > We are working through some performance issues with changes made to the compiled model in EF8 and EF9. See [Issue 33483#](https://github.com/dotnet/efcore/issues/33483) for more information. + + +### Read-only primitive collections + +> [!TIP] +> The code shown here comes from [PrimitiveCollectionsSample.cs](https://github.com/dotnet/EntityFramework.Docs/tree/main/samples/core/Miscellaneous/NewInEFCore9/PrimitiveCollectionsSample.cs). + +EF8 introduced support for [mapping arrays and mutable lists of primitive types](xref:core/what-is-new/ef-core-8.0/whatsnew#primitive-collections). This has been expanded in EF9 to include read-only collections/lists. Specifically, EF9 supports collections typed as `IReadOnlyList`, `IReadOnlyCollection`, or `ReadOnlyCollection`. For example, in the following code, `DaysVisited` will be mapped by convention as a primitive collection of dates: + +```csharp +public class DogWalk +{ + public int Id { get; set; } + public string Name { get; set; } + public ReadOnlyCollection DaysVisited { get; set; } +} +``` + +The read-only collection can be backed by a normal, mutable collection if desired. For example, in the following code, `DaysVisited` can be mapped as a primitive collection of dates, while still allowing code in the class to manipulate the underlying list. + +```csharp + public class Pub + { + public int Id { get; set; } + public string Name { get; set; } + public IReadOnlyCollection Beers { get; set; } + + private List _daysVisited = new(); + public IReadOnlyList DaysVisited => _daysVisited; + } +``` + +These collections can then be used in queries in the normal way. For example, this LINQ query: + + +[!code-csharp[WalksWithADrink](../../../../samples/core/Miscellaneous/NewInEFCore9/PrimitiveCollectionsSample.cs?name=WalksWithADrink)] + +Which translates to the following SQL on SQLite: + +```sql +SELECT "w"."Name" AS "WalkName", "p"."Name" AS "PubName", ( + SELECT COUNT(*) + FROM json_each("w"."DaysVisited") AS "d" + WHERE "d"."value" IN ( + SELECT "d0"."value" + FROM json_each("p"."DaysVisited") AS "d0" + )) AS "Count", json_array_length("w"."DaysVisited") AS "TotalCount" +FROM "Walks" AS "w" +INNER JOIN "Pubs" AS "p" ON "w"."ClosestPubId" = "p"."Id" +``` + ### Specify caching for sequences @@ -770,9 +928,6 @@ CREATE INDEX [IX_User_Name] ON [User] ([Name]) WITH (FILLFACTOR = 80); CREATE INDEX [IX_User_Region_Tag] ON [User] ([Region], [Tag]) WITH (FILLFACTOR = 80); ``` -> [!NOTE] -> There is currently a bug in preview 2 where the fill-factors are not included when the table is created for the first time. This is tracked by [Issue #33269](https://github.com/dotnet/efcore/issues/33269) - This enhancement was contributed by [@deano-hunter](https://github.com/deano-hunter). Many thanks! diff --git a/entity-framework/core/what-is-new/index.md b/entity-framework/core/what-is-new/index.md index cfda4bddf7..913eab0c7c 100644 --- a/entity-framework/core/what-is-new/index.md +++ b/entity-framework/core/what-is-new/index.md @@ -48,4 +48,4 @@ See the [release planning process](xref:core/what-is-new/release-planning) for m The next planned stable release is **EF Core 9.0**, or just **EF9**, scheduled for **November 2024**. -See the [high-level plan for EF9](xref:core/what-is-new/ef-core-9.0/plan) for more information. +See the [What's New in EF9](xref:core/what-is-new/ef-core-9.0/whatsnew) for more information. diff --git a/samples/core/Benchmarks/AverageBlogRanking.cs b/samples/core/Benchmarks/AverageBlogRanking.cs index 670eaf614f..19dc70bf8b 100644 --- a/samples/core/Benchmarks/AverageBlogRanking.cs +++ b/samples/core/Benchmarks/AverageBlogRanking.cs @@ -83,7 +83,7 @@ public class BloggingContext : DbContext public DbSet Blogs { get; set; } protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) - => optionsBuilder.UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=Blogging;Trusted_Connection=True"); + => optionsBuilder.UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=Blogging;Trusted_Connection=True;ConnectRetryCount=0"); public void SeedData(int numblogs) { diff --git a/samples/core/Benchmarks/CompiledQueries.cs b/samples/core/Benchmarks/CompiledQueries.cs index 587f1fe98b..aa10ed1a29 100644 --- a/samples/core/Benchmarks/CompiledQueries.cs +++ b/samples/core/Benchmarks/CompiledQueries.cs @@ -62,7 +62,7 @@ public class BloggingContext : DbContext protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => optionsBuilder - .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=Blogging;Trusted_Connection=True") + .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=Blogging;Trusted_Connection=True;ConnectRetryCount=0") .UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking); public async Task SeedDataAsync(int numBlogs) diff --git a/samples/core/Benchmarks/ContextPooling.cs b/samples/core/Benchmarks/ContextPooling.cs index fa0899e445..68ae552a12 100644 --- a/samples/core/Benchmarks/ContextPooling.cs +++ b/samples/core/Benchmarks/ContextPooling.cs @@ -17,7 +17,7 @@ public class ContextPooling public void Setup() { _options = new DbContextOptionsBuilder() - .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=Blogging;Trusted_Connection=True") + .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=Blogging;Trusted_Connection=True;ConnectRetryCount=0") .Options; using var context = new BloggingContext(_options); diff --git a/samples/core/Benchmarks/DynamicallyConstructedQueries.cs b/samples/core/Benchmarks/DynamicallyConstructedQueries.cs index cbd81594d7..a6cfa4dde9 100644 --- a/samples/core/Benchmarks/DynamicallyConstructedQueries.cs +++ b/samples/core/Benchmarks/DynamicallyConstructedQueries.cs @@ -109,7 +109,7 @@ public class BloggingContext : DbContext public DbSet Posts { get; set; } protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) - => optionsBuilder.UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=Blogging;Trusted_Connection=True"); + => optionsBuilder.UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=Blogging;Trusted_Connection=True;ConnectRetryCount=0"); } public class Blog diff --git a/samples/core/Benchmarks/Inheritance.cs b/samples/core/Benchmarks/Inheritance.cs index dbc45195b6..40f864bf57 100644 --- a/samples/core/Benchmarks/Inheritance.cs +++ b/samples/core/Benchmarks/Inheritance.cs @@ -72,7 +72,7 @@ public abstract class InheritanceContext : DbContext public DbSet Roots { get; set; } protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) - => optionsBuilder.UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=Blogging;Trusted_Connection=True"); + => optionsBuilder.UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=Blogging;Trusted_Connection=True;ConnectRetryCount=0"); protected override void OnModelCreating(ModelBuilder modelBuilder) { diff --git a/samples/core/Benchmarks/QueryTrackingBehavior.cs b/samples/core/Benchmarks/QueryTrackingBehavior.cs index c2f70372b4..32eaad6422 100644 --- a/samples/core/Benchmarks/QueryTrackingBehavior.cs +++ b/samples/core/Benchmarks/QueryTrackingBehavior.cs @@ -48,7 +48,7 @@ public class BloggingContext : DbContext public DbSet Posts { get; set; } protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) - => optionsBuilder.UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=Blogging;Trusted_Connection=True"); + => optionsBuilder.UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=Blogging;Trusted_Connection=True;ConnectRetryCount=0"); public static void SeedData(int numBlogs, int numPostsPerBlog) { @@ -77,4 +77,4 @@ public class Post public int BlogId { get; set; } public Blog Blog { get; set; } } -} \ No newline at end of file +} diff --git a/samples/core/CascadeDeletes/IntroOptionalSamples.cs b/samples/core/CascadeDeletes/IntroOptionalSamples.cs index 5dd1879cc6..302c0c0bb0 100644 --- a/samples/core/CascadeDeletes/IntroOptionalSamples.cs +++ b/samples/core/CascadeDeletes/IntroOptionalSamples.cs @@ -159,7 +159,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder .EnableSensitiveDataLogging() - .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=Scratch;Trusted_Connection=True"); + .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=Scratch;Trusted_Connection=True;ConnectRetryCount=0"); //.UseSqlite("DataSource=test.db"); if (!_quiet) @@ -167,4 +167,4 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) optionsBuilder.LogTo(Console.WriteLine, new[] { RelationalEventId.CommandExecuted }); } } -} \ No newline at end of file +} diff --git a/samples/core/CascadeDeletes/IntroRequiredSamples.cs b/samples/core/CascadeDeletes/IntroRequiredSamples.cs index cc318d1142..73a1873da5 100644 --- a/samples/core/CascadeDeletes/IntroRequiredSamples.cs +++ b/samples/core/CascadeDeletes/IntroRequiredSamples.cs @@ -176,7 +176,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder .EnableSensitiveDataLogging() - .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=Scratch;Trusted_Connection=True"); + .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=Scratch;Trusted_Connection=True;ConnectRetryCount=0"); //.UseSqlite("DataSource=test.db"); if (!_quiet) @@ -184,4 +184,4 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) optionsBuilder.LogTo(Console.WriteLine, new[] { RelationalEventId.CommandExecuted }); } } -} \ No newline at end of file +} diff --git a/samples/core/CascadeDeletes/OptionalDependentsSamples.cs b/samples/core/CascadeDeletes/OptionalDependentsSamples.cs index 0585730316..b6ee4c779b 100644 --- a/samples/core/CascadeDeletes/OptionalDependentsSamples.cs +++ b/samples/core/CascadeDeletes/OptionalDependentsSamples.cs @@ -187,7 +187,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) optionsBuilder .EnableServiceProviderCaching(false) .EnableSensitiveDataLogging() - .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=Scratch;Trusted_Connection=True"); + .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=Scratch;Trusted_Connection=True;ConnectRetryCount=0"); //.UseSqlite("DataSource=test.db"); if (!_quiet) @@ -196,4 +196,4 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) } } } -} \ No newline at end of file +} diff --git a/samples/core/CascadeDeletes/RequiredDependentsSamples.cs b/samples/core/CascadeDeletes/RequiredDependentsSamples.cs index eda55142a8..2ec40840bb 100644 --- a/samples/core/CascadeDeletes/RequiredDependentsSamples.cs +++ b/samples/core/CascadeDeletes/RequiredDependentsSamples.cs @@ -192,7 +192,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) optionsBuilder .EnableServiceProviderCaching(false) .EnableSensitiveDataLogging() - .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=Scratch;Trusted_Connection=True"); + .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=Scratch;Trusted_Connection=True;ConnectRetryCount=0"); //.UseSqlite("DataSource=test.db"); if (!_quiet) @@ -201,4 +201,4 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) } } } -} \ No newline at end of file +} diff --git a/samples/core/CascadeDeletes/WithDatabaseCycleSamples.cs b/samples/core/CascadeDeletes/WithDatabaseCycleSamples.cs index 90e7659bae..70c4d39f88 100644 --- a/samples/core/CascadeDeletes/WithDatabaseCycleSamples.cs +++ b/samples/core/CascadeDeletes/WithDatabaseCycleSamples.cs @@ -169,7 +169,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder .EnableSensitiveDataLogging() - .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=Scratch;Trusted_Connection=True"); + .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=Scratch;Trusted_Connection=True;ConnectRetryCount=0"); //.UseSqlite("DataSource=test.db"); if (!_quiet) @@ -177,4 +177,4 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) optionsBuilder.LogTo(Console.WriteLine, new[] { RelationalEventId.CommandExecuted }); } } -} \ No newline at end of file +} diff --git a/samples/core/DbContextPooling/Program.cs b/samples/core/DbContextPooling/Program.cs index 78f14a0002..b46fb23195 100644 --- a/samples/core/DbContextPooling/Program.cs +++ b/samples/core/DbContextPooling/Program.cs @@ -38,7 +38,7 @@ public class BlogController public class Startup { private const string ConnectionString - = @"Server=(localdb)\mssqllocaldb;Database=Demo.ContextPooling;Trusted_Connection=True"; + = @"Server=(localdb)\mssqllocaldb;Database=Demo.ContextPooling;Trusted_Connection=True;ConnectRetryCount=0"; public void ConfigureServices(IServiceCollection services) { @@ -136,4 +136,4 @@ private static async Task MonitorResults(TimeSpan duration, Stopwatch stopwatch) stopwatch.Stop(); } -} \ No newline at end of file +} diff --git a/samples/core/Intro/Model.cs b/samples/core/Intro/Model.cs index 5f912c47aa..00b0c9250a 100644 --- a/samples/core/Intro/Model.cs +++ b/samples/core/Intro/Model.cs @@ -11,7 +11,7 @@ public class BloggingContext : DbContext protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder.UseSqlServer( - @"Server=(localdb)\mssqllocaldb;Database=Blogging;Trusted_Connection=True"); + @"Server=(localdb)\mssqllocaldb;Database=Blogging;Trusted_Connection=True;ConnectRetryCount=0"); } } @@ -31,4 +31,4 @@ public class Post public int BlogId { get; set; } public Blog Blog { get; set; } -} \ No newline at end of file +} diff --git a/samples/core/Miscellaneous/Async/Program.cs b/samples/core/Miscellaneous/Async/Program.cs index 8f4d268453..5b6c5a847c 100644 --- a/samples/core/Miscellaneous/Async/Program.cs +++ b/samples/core/Miscellaneous/Async/Program.cs @@ -30,7 +30,7 @@ public class BloggingContext : DbContext protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { - optionsBuilder.UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=EFAsync;Trusted_Connection=True"); + optionsBuilder.UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=EFAsync;Trusted_Connection=True;ConnectRetryCount=0"); } } @@ -39,4 +39,4 @@ public class Blog public int BlogId { get; set; } public string Url { get; set; } public int Rating { get; set; } -} \ No newline at end of file +} diff --git a/samples/core/Miscellaneous/AsyncWithSystemInteractive/Program.cs b/samples/core/Miscellaneous/AsyncWithSystemInteractive/Program.cs index 5cac9008c0..4d76d32e21 100644 --- a/samples/core/Miscellaneous/AsyncWithSystemInteractive/Program.cs +++ b/samples/core/Miscellaneous/AsyncWithSystemInteractive/Program.cs @@ -29,7 +29,7 @@ public class BloggingContext : DbContext protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { - optionsBuilder.UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=EFAsync;Trusted_Connection=True"); + optionsBuilder.UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=EFAsync;Trusted_Connection=True;ConnectRetryCount=0"); } } @@ -38,4 +38,4 @@ public class Blog public int BlogId { get; set; } public string Url { get; set; } public int Rating { get; set; } -} \ No newline at end of file +} diff --git a/samples/core/Miscellaneous/Collations/Program.cs b/samples/core/Miscellaneous/Collations/Program.cs index 04657c5023..e045cfaf40 100644 --- a/samples/core/Miscellaneous/Collations/Program.cs +++ b/samples/core/Miscellaneous/Collations/Program.cs @@ -30,7 +30,7 @@ public class CustomerContext : DbContext protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { - optionsBuilder.UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=EFCollations;Trusted_Connection=True"); + optionsBuilder.UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=EFCollations;Trusted_Connection=True;ConnectRetryCount=0"); } protected override void OnModelCreating(ModelBuilder modelBuilder) @@ -50,4 +50,4 @@ public class Customer { public int Id { get; set; } public string Name { get; set; } -} \ No newline at end of file +} diff --git a/samples/core/Miscellaneous/ConfiguringDbContext/AdditionalConfiguration/ApplicationDbContext.cs b/samples/core/Miscellaneous/ConfiguringDbContext/AdditionalConfiguration/ApplicationDbContext.cs index cac31036b8..52136616b7 100644 --- a/samples/core/Miscellaneous/ConfiguringDbContext/AdditionalConfiguration/ApplicationDbContext.cs +++ b/samples/core/Miscellaneous/ConfiguringDbContext/AdditionalConfiguration/ApplicationDbContext.cs @@ -9,7 +9,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder .EnableSensitiveDataLogging() - .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=Test"); + .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=Test;ConnectRetryCount=0"); } } -#endregion \ No newline at end of file +#endregion diff --git a/samples/core/Miscellaneous/ConfiguringDbContext/WebApp/UseNewForWebApp.cs b/samples/core/Miscellaneous/ConfiguringDbContext/WebApp/UseNewForWebApp.cs index a106307a90..27a4aa1f3e 100644 --- a/samples/core/Miscellaneous/ConfiguringDbContext/WebApp/UseNewForWebApp.cs +++ b/samples/core/Miscellaneous/ConfiguringDbContext/WebApp/UseNewForWebApp.cs @@ -8,10 +8,10 @@ public static void Example() { #region UseNewForWebApp var contextOptions = new DbContextOptionsBuilder() - .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=Test") + .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=Test;ConnectRetryCount=0") .Options; using var context = new ApplicationDbContext(contextOptions); #endregion } -} \ No newline at end of file +} diff --git a/samples/core/Miscellaneous/ConfiguringDbContext/WithContextFactory/FactoryServicesExample.cs b/samples/core/Miscellaneous/ConfiguringDbContext/WithContextFactory/FactoryServicesExample.cs index f7222c3385..034058717a 100644 --- a/samples/core/Miscellaneous/ConfiguringDbContext/WithContextFactory/FactoryServicesExample.cs +++ b/samples/core/Miscellaneous/ConfiguringDbContext/WithContextFactory/FactoryServicesExample.cs @@ -11,7 +11,7 @@ public void ConfigureServices(IServiceCollection services) { services.AddDbContextFactory( options => - options.UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=Test")); + options.UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=Test;ConnectRetryCount=0")); } #endregion -} \ No newline at end of file +} diff --git a/samples/core/Miscellaneous/ConfiguringDbContext/WithNew/ApplicationDbContext.cs b/samples/core/Miscellaneous/ConfiguringDbContext/WithNew/ApplicationDbContext.cs index 4c719ac005..70df3560a3 100644 --- a/samples/core/Miscellaneous/ConfiguringDbContext/WithNew/ApplicationDbContext.cs +++ b/samples/core/Miscellaneous/ConfiguringDbContext/WithNew/ApplicationDbContext.cs @@ -7,7 +7,7 @@ public class ApplicationDbContext : DbContext { protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { - optionsBuilder.UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=Test"); + optionsBuilder.UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=Test;ConnectRetryCount=0"); } } -#endregion \ No newline at end of file +#endregion diff --git a/samples/core/Miscellaneous/ConnectionInterception/BlogsContext.cs b/samples/core/Miscellaneous/ConnectionInterception/BlogsContext.cs index a1f0650967..1fce0ff8a5 100644 --- a/samples/core/Miscellaneous/ConnectionInterception/BlogsContext.cs +++ b/samples/core/Miscellaneous/ConnectionInterception/BlogsContext.cs @@ -4,7 +4,7 @@ public class BlogsContext : DbContext { - private const string ConnectionString = @"Server=(localdb)\mssqllocaldb;Database=InterceptionTest;Trusted_Connection=True"; + private const string ConnectionString = @"Server=(localdb)\mssqllocaldb;Database=InterceptionTest;Trusted_Connection=True;ConnectRetryCount=0"; private static readonly AadAuthenticationInterceptor _interceptor = new AadAuthenticationInterceptor(); diff --git a/samples/core/Miscellaneous/ConnectionResiliency/Program.cs b/samples/core/Miscellaneous/ConnectionResiliency/Program.cs index de75f7fc6b..67eeb28cf5 100644 --- a/samples/core/Miscellaneous/ConnectionResiliency/Program.cs +++ b/samples/core/Miscellaneous/ConnectionResiliency/Program.cs @@ -130,7 +130,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder .UseSqlServer( - @"Server=(localdb)\mssqllocaldb;Database=EFMiscellanous.ConnectionResiliency;Trusted_Connection=True", + @"Server=(localdb)\mssqllocaldb;Database=EFMiscellanous.ConnectionResiliency;Trusted_Connection=True;ConnectRetryCount=0", options => options.EnableRetryOnFailure()); } #endregion diff --git a/samples/core/Miscellaneous/Logging/Logging/BloggingContext.cs b/samples/core/Miscellaneous/Logging/Logging/BloggingContext.cs index 216b54b04e..16283d63f9 100644 --- a/samples/core/Miscellaneous/Logging/Logging/BloggingContext.cs +++ b/samples/core/Miscellaneous/Logging/Logging/BloggingContext.cs @@ -17,7 +17,7 @@ public static readonly ILoggerFactory MyLoggerFactory protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => optionsBuilder .UseLoggerFactory(MyLoggerFactory) - .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=EFLogging;Trusted_Connection=True"); + .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=EFLogging;Trusted_Connection=True;ConnectRetryCount=0"); #endregion } @@ -65,4 +65,4 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => optionsBuilder .ConfigureWarnings(b => b.Throw(RelationalEventId.QueryPossibleUnintendedUseOfEqualsWarning)); #endregion -} \ No newline at end of file +} diff --git a/samples/core/Miscellaneous/Logging/Logging/BloggingContextWithFiltering.cs b/samples/core/Miscellaneous/Logging/Logging/BloggingContextWithFiltering.cs index 2f5a7daf0b..164b647265 100644 --- a/samples/core/Miscellaneous/Logging/Logging/BloggingContextWithFiltering.cs +++ b/samples/core/Miscellaneous/Logging/Logging/BloggingContextWithFiltering.cs @@ -26,6 +26,6 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => optionsBuilder .UseLoggerFactory(MyLoggerFactory) // Warning: Do not create a new ILoggerFactory instance each time .UseSqlServer( - @"Server=(localdb)\mssqllocaldb;Database=EFLogging;Trusted_Connection=True"); + @"Server=(localdb)\mssqllocaldb;Database=EFLogging;Trusted_Connection=True;ConnectRetryCount=0"); #endregion -} \ No newline at end of file +} diff --git a/samples/core/Miscellaneous/NewInEFCore6/ArrayParametersSample.cs b/samples/core/Miscellaneous/NewInEFCore6/ArrayParametersSample.cs index 959883e652..75d33e224e 100644 --- a/samples/core/Miscellaneous/NewInEFCore6/ArrayParametersSample.cs +++ b/samples/core/Miscellaneous/NewInEFCore6/ArrayParametersSample.cs @@ -61,7 +61,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder .EnableSensitiveDataLogging() - .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=EFCoreSample"); + .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=EFCoreSample;ConnectRetryCount=0"); if (!_quiet) { diff --git a/samples/core/Miscellaneous/NewInEFCore6/BoolToStringTranslationSample.cs b/samples/core/Miscellaneous/NewInEFCore6/BoolToStringTranslationSample.cs index 889a3cf209..685c2748fd 100644 --- a/samples/core/Miscellaneous/NewInEFCore6/BoolToStringTranslationSample.cs +++ b/samples/core/Miscellaneous/NewInEFCore6/BoolToStringTranslationSample.cs @@ -95,7 +95,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder .EnableSensitiveDataLogging() - .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=EFCoreSample"); + .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=EFCoreSample;ConnectRetryCount=0"); if (!_quiet) { diff --git a/samples/core/Miscellaneous/NewInEFCore6/ColumnOrderSample.cs b/samples/core/Miscellaneous/NewInEFCore6/ColumnOrderSample.cs index 87c0814783..011161d1bc 100644 --- a/samples/core/Miscellaneous/NewInEFCore6/ColumnOrderSample.cs +++ b/samples/core/Miscellaneous/NewInEFCore6/ColumnOrderSample.cs @@ -153,7 +153,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder .EnableSensitiveDataLogging() - .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=EFCoreSample"); + .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=EFCoreSample;ConnectRetryCount=0"); if (!_quiet) { diff --git a/samples/core/Miscellaneous/NewInEFCore6/CommandSourceSample.cs b/samples/core/Miscellaneous/NewInEFCore6/CommandSourceSample.cs index af4c4a551a..f2b29eb3f4 100644 --- a/samples/core/Miscellaneous/NewInEFCore6/CommandSourceSample.cs +++ b/samples/core/Miscellaneous/NewInEFCore6/CommandSourceSample.cs @@ -23,7 +23,7 @@ public static void Interceptors_get_the_source_of_the_command() }); context.SaveChanges(); - + context.ChangeTracker.Clear(); var customers = context.Customers.ToList(); @@ -64,7 +64,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) optionsBuilder .EnableSensitiveDataLogging() .AddInterceptors(new CommandSourceInterceptor()) - .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=EFCoreSample"); + .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=EFCoreSample;ConnectRetryCount=0"); } } } diff --git a/samples/core/Miscellaneous/NewInEFCore6/ContainsFreeTextSample.cs b/samples/core/Miscellaneous/NewInEFCore6/ContainsFreeTextSample.cs index a2f0c3df7b..72abcbc68c 100644 --- a/samples/core/Miscellaneous/NewInEFCore6/ContainsFreeTextSample.cs +++ b/samples/core/Miscellaneous/NewInEFCore6/ContainsFreeTextSample.cs @@ -124,7 +124,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder .EnableSensitiveDataLogging() - .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=EFCoreSample"); + .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=EFCoreSample;ConnectRetryCount=0"); if (!_quiet) { diff --git a/samples/core/Miscellaneous/NewInEFCore6/ConvertNullsSample.cs b/samples/core/Miscellaneous/NewInEFCore6/ConvertNullsSample.cs index c889ed0d85..e78a9c2d23 100644 --- a/samples/core/Miscellaneous/NewInEFCore6/ConvertNullsSample.cs +++ b/samples/core/Miscellaneous/NewInEFCore6/ConvertNullsSample.cs @@ -151,7 +151,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder .EnableSensitiveDataLogging() - .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=EFCoreSample"); + .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=EFCoreSample;ConnectRetryCount=0"); if (!_quiet) { @@ -214,7 +214,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder .EnableSensitiveDataLogging() - .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=EFCoreSample"); + .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=EFCoreSample;ConnectRetryCount=0"); if (!_quiet) { diff --git a/samples/core/Miscellaneous/NewInEFCore6/DbContextFactorySample.cs b/samples/core/Miscellaneous/NewInEFCore6/DbContextFactorySample.cs index 3f0b23bf7d..cf4a12d919 100644 --- a/samples/core/Miscellaneous/NewInEFCore6/DbContextFactorySample.cs +++ b/samples/core/Miscellaneous/NewInEFCore6/DbContextFactorySample.cs @@ -12,7 +12,7 @@ public static void Ignore_parameterless_constructor_when_creating_DbContext_from var services = new ServiceCollection() .AddDbContextFactory( - builder => builder.UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=EFCoreSample")) + builder => builder.UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=EFCoreSample;ConnectRetryCount=0")) .BuildServiceProvider(); var factory = services.GetService>(); @@ -32,7 +32,7 @@ public static void AddDbContextFactory_also_registers_scoped_DbContext_instance( #region Registration var container = services .AddDbContextFactory( - builder => builder.UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=EFCoreSample")) + builder => builder.UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=EFCoreSample;ConnectRetryCount=0")) .BuildServiceProvider(); #endregion @@ -93,7 +93,7 @@ public void DoSomething() var results1 = context1.Blogs.ToList(); var results2 = context2.Blogs.ToList(); - + // Contexts obtained from the factory must be explicitly disposed } } @@ -115,7 +115,7 @@ public SomeDbContext(DbContextOptions options) : base(options) { } - + public DbSet Blogs { get; set; } } #endregion diff --git a/samples/core/Miscellaneous/NewInEFCore6/EntityTypeConfigurationAttributeSample.cs b/samples/core/Miscellaneous/NewInEFCore6/EntityTypeConfigurationAttributeSample.cs index c0d1e6d30d..00863f4302 100644 --- a/samples/core/Miscellaneous/NewInEFCore6/EntityTypeConfigurationAttributeSample.cs +++ b/samples/core/Miscellaneous/NewInEFCore6/EntityTypeConfigurationAttributeSample.cs @@ -84,7 +84,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder .EnableSensitiveDataLogging() - .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=EFCoreSample"); + .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=EFCoreSample;ConnectRetryCount=0"); if (!_quiet) { diff --git a/samples/core/Miscellaneous/NewInEFCore6/GroupBySample.cs b/samples/core/Miscellaneous/NewInEFCore6/GroupBySample.cs index 8825686d6b..554dca5e8f 100644 --- a/samples/core/Miscellaneous/NewInEFCore6/GroupBySample.cs +++ b/samples/core/Miscellaneous/NewInEFCore6/GroupBySample.cs @@ -547,7 +547,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder .EnableSensitiveDataLogging() - .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=EFCoreSample"); + .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=EFCoreSample;ConnectRetryCount=0"); if (!_quiet) { diff --git a/samples/core/Miscellaneous/NewInEFCore6/HasConversionSample.cs b/samples/core/Miscellaneous/NewInEFCore6/HasConversionSample.cs index d674780a98..6de0b391d6 100644 --- a/samples/core/Miscellaneous/NewInEFCore6/HasConversionSample.cs +++ b/samples/core/Miscellaneous/NewInEFCore6/HasConversionSample.cs @@ -124,7 +124,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder .EnableSensitiveDataLogging() - .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=EFCoreSample"); + .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=EFCoreSample;ConnectRetryCount=0"); if (!_quiet) { diff --git a/samples/core/Miscellaneous/NewInEFCore6/IsNullOrWhitespaceSample.cs b/samples/core/Miscellaneous/NewInEFCore6/IsNullOrWhitespaceSample.cs index 28e65299fa..c70a067906 100644 --- a/samples/core/Miscellaneous/NewInEFCore6/IsNullOrWhitespaceSample.cs +++ b/samples/core/Miscellaneous/NewInEFCore6/IsNullOrWhitespaceSample.cs @@ -98,7 +98,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder .EnableSensitiveDataLogging() - .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=EFCoreSample"); + .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=EFCoreSample;ConnectRetryCount=0"); if (!_quiet) { diff --git a/samples/core/Miscellaneous/NewInEFCore6/ManyToManyConfigurationSample.cs b/samples/core/Miscellaneous/NewInEFCore6/ManyToManyConfigurationSample.cs index d865977e40..0019756eac 100644 --- a/samples/core/Miscellaneous/NewInEFCore6/ManyToManyConfigurationSample.cs +++ b/samples/core/Miscellaneous/NewInEFCore6/ManyToManyConfigurationSample.cs @@ -31,7 +31,7 @@ public static void ManyToManyTest() Console.WriteLine(context.Model.ToDebugString()); Console.WriteLine(); - + context.Log = true; context.Database.EnsureCreated(); context.Log = false; @@ -50,7 +50,7 @@ public static void ManyToManyTest() context.SaveChanges(); } - + Console.WriteLine(); using (var context = new TContext()) @@ -77,7 +77,7 @@ public class Human public string Name { get; set; } public ICollection Cats { get; } = new List(); } - + public class CatHuman { public int CatsId { get; set; } @@ -168,7 +168,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder .EnableSensitiveDataLogging() - .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=EFCoreSample"); + .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=EFCoreSample;ConnectRetryCount=0"); optionsBuilder.LogTo( s => diff --git a/samples/core/Miscellaneous/NewInEFCore6/MathFTranslationSample.cs b/samples/core/Miscellaneous/NewInEFCore6/MathFTranslationSample.cs index d758826e78..2431e88399 100644 --- a/samples/core/Miscellaneous/NewInEFCore6/MathFTranslationSample.cs +++ b/samples/core/Miscellaneous/NewInEFCore6/MathFTranslationSample.cs @@ -91,7 +91,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder .EnableSensitiveDataLogging() - .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=EFCoreSample"); + .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=EFCoreSample;ConnectRetryCount=0"); if (!_quiet) { diff --git a/samples/core/Miscellaneous/NewInEFCore6/MinimalApiSample.cs b/samples/core/Miscellaneous/NewInEFCore6/MinimalApiSample.cs index 792de7a29e..8d6729ceee 100644 --- a/samples/core/Miscellaneous/NewInEFCore6/MinimalApiSample.cs +++ b/samples/core/Miscellaneous/NewInEFCore6/MinimalApiSample.cs @@ -7,10 +7,10 @@ public static class MinimalApiSample public static void Add_a_DbContext_and_provider() { Console.WriteLine($">>>> Sample: {nameof(Add_a_DbContext_and_provider)}"); - + SqliteMinimal(null); SqliteNormal(null); - + SqlServerMinimal(null); SqlServerNormal(null); } @@ -49,7 +49,7 @@ private static void SqlServerNormal(string[] args) var builder = WebApplication.CreateBuilder(args); builder.Services.AddDbContext( - options => options.UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=MyDatabase")); + options => options.UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=MyDatabase;ConnectRetryCount=0")); #endregion } diff --git a/samples/core/Miscellaneous/NewInEFCore6/OptionalDependentsSample.cs b/samples/core/Miscellaneous/NewInEFCore6/OptionalDependentsSample.cs index 17efe88e49..9e7f11f958 100644 --- a/samples/core/Miscellaneous/NewInEFCore6/OptionalDependentsSample.cs +++ b/samples/core/Miscellaneous/NewInEFCore6/OptionalDependentsSample.cs @@ -580,7 +580,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder .EnableSensitiveDataLogging() - .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=EFCoreSample"); + .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=EFCoreSample;ConnectRetryCount=0"); if (!_quiet) { diff --git a/samples/core/Miscellaneous/NewInEFCore6/PreConventionModelConfigurationSample.cs b/samples/core/Miscellaneous/NewInEFCore6/PreConventionModelConfigurationSample.cs index 7cc8837703..c3171b9833 100644 --- a/samples/core/Miscellaneous/NewInEFCore6/PreConventionModelConfigurationSample.cs +++ b/samples/core/Miscellaneous/NewInEFCore6/PreConventionModelConfigurationSample.cs @@ -144,7 +144,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder .EnableSensitiveDataLogging() - .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=EFCoreSample"); + .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=EFCoreSample;ConnectRetryCount=0"); //if (!_quiet) { diff --git a/samples/core/Miscellaneous/NewInEFCore6/PrecisionAttributeSample.cs b/samples/core/Miscellaneous/NewInEFCore6/PrecisionAttributeSample.cs index 2d9e953987..96dcc663c6 100644 --- a/samples/core/Miscellaneous/NewInEFCore6/PrecisionAttributeSample.cs +++ b/samples/core/Miscellaneous/NewInEFCore6/PrecisionAttributeSample.cs @@ -65,7 +65,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder .EnableSensitiveDataLogging() - .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=EFCoreSample"); + .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=EFCoreSample;ConnectRetryCount=0"); if (!_quiet) { diff --git a/samples/core/Miscellaneous/NewInEFCore6/PublicPooledDbContextFactorySample.cs b/samples/core/Miscellaneous/NewInEFCore6/PublicPooledDbContextFactorySample.cs index 62ab79d87f..2ffad55c0f 100644 --- a/samples/core/Miscellaneous/NewInEFCore6/PublicPooledDbContextFactorySample.cs +++ b/samples/core/Miscellaneous/NewInEFCore6/PublicPooledDbContextFactorySample.cs @@ -12,7 +12,7 @@ public static void Can_create_pooled_DbContext_factory() #region CreatePool var options = new DbContextOptionsBuilder() .EnableSensitiveDataLogging() - .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=EFCoreSample") + .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=EFCoreSample;ConnectRetryCount=0") .Options; var factory = new PooledDbContextFactory(options); diff --git a/samples/core/Miscellaneous/NewInEFCore6/RandomFunctionSample.cs b/samples/core/Miscellaneous/NewInEFCore6/RandomFunctionSample.cs index 5720b7e4bf..3ae68e3281 100644 --- a/samples/core/Miscellaneous/NewInEFCore6/RandomFunctionSample.cs +++ b/samples/core/Miscellaneous/NewInEFCore6/RandomFunctionSample.cs @@ -79,7 +79,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder .EnableSensitiveDataLogging() - .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=EFCoreSample"); + .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=EFCoreSample;ConnectRetryCount=0"); if (!_quiet) { diff --git a/samples/core/Miscellaneous/NewInEFCore6/SparseColumnsSample.cs b/samples/core/Miscellaneous/NewInEFCore6/SparseColumnsSample.cs index 31947e78ce..d3ceeb7bef 100644 --- a/samples/core/Miscellaneous/NewInEFCore6/SparseColumnsSample.cs +++ b/samples/core/Miscellaneous/NewInEFCore6/SparseColumnsSample.cs @@ -78,7 +78,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder .EnableSensitiveDataLogging() - .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=EFCoreSample"); + .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=EFCoreSample;ConnectRetryCount=0"); if (!_quiet) { diff --git a/samples/core/Miscellaneous/NewInEFCore6/SplitQuerySample.cs b/samples/core/Miscellaneous/NewInEFCore6/SplitQuerySample.cs index 2f8584379e..6ae9ffd1cd 100644 --- a/samples/core/Miscellaneous/NewInEFCore6/SplitQuerySample.cs +++ b/samples/core/Miscellaneous/NewInEFCore6/SplitQuerySample.cs @@ -176,7 +176,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder .EnableSensitiveDataLogging() - .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=EFCoreSample"); + .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=EFCoreSample;ConnectRetryCount=0"); if (!_quiet) { diff --git a/samples/core/Miscellaneous/NewInEFCore6/StringConcatSample.cs b/samples/core/Miscellaneous/NewInEFCore6/StringConcatSample.cs index 0997acd2fa..a4d083d26e 100644 --- a/samples/core/Miscellaneous/NewInEFCore6/StringConcatSample.cs +++ b/samples/core/Miscellaneous/NewInEFCore6/StringConcatSample.cs @@ -116,7 +116,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder .EnableSensitiveDataLogging() - .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=EFCoreSample"); + .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=EFCoreSample;ConnectRetryCount=0"); if (!_quiet) { diff --git a/samples/core/Miscellaneous/NewInEFCore6/SubstringTranslationSample.cs b/samples/core/Miscellaneous/NewInEFCore6/SubstringTranslationSample.cs index 00d3fbe39b..09f2c54a22 100644 --- a/samples/core/Miscellaneous/NewInEFCore6/SubstringTranslationSample.cs +++ b/samples/core/Miscellaneous/NewInEFCore6/SubstringTranslationSample.cs @@ -79,7 +79,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder .EnableSensitiveDataLogging() - .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=EFCoreSample"); + .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=EFCoreSample;ConnectRetryCount=0"); if (!_quiet) { diff --git a/samples/core/Miscellaneous/NewInEFCore6/TagWithFileAndLineSample.cs b/samples/core/Miscellaneous/NewInEFCore6/TagWithFileAndLineSample.cs index e2a0e4ea38..6d17211929 100644 --- a/samples/core/Miscellaneous/NewInEFCore6/TagWithFileAndLineSample.cs +++ b/samples/core/Miscellaneous/NewInEFCore6/TagWithFileAndLineSample.cs @@ -88,7 +88,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder .EnableSensitiveDataLogging() - .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=EFCoreSample"); + .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=EFCoreSample;ConnectRetryCount=0"); if (!_quiet) { diff --git a/samples/core/Miscellaneous/NewInEFCore6/TemporalTablesSample.cs b/samples/core/Miscellaneous/NewInEFCore6/TemporalTablesSample.cs index cb531ffdfa..fef92f1eb1 100644 --- a/samples/core/Miscellaneous/NewInEFCore6/TemporalTablesSample.cs +++ b/samples/core/Miscellaneous/NewInEFCore6/TemporalTablesSample.cs @@ -290,7 +290,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder .EnableSensitiveDataLogging() - .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=EFCoreSample"); + .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=EFCoreSample;ConnectRetryCount=0"); if (!_quiet) { diff --git a/samples/core/Miscellaneous/NewInEFCore6/TemporaryValuesSample.cs b/samples/core/Miscellaneous/NewInEFCore6/TemporaryValuesSample.cs index d59bd7e204..fc120a4a01 100644 --- a/samples/core/Miscellaneous/NewInEFCore6/TemporaryValuesSample.cs +++ b/samples/core/Miscellaneous/NewInEFCore6/TemporaryValuesSample.cs @@ -140,7 +140,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder .EnableSensitiveDataLogging() - .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=EFCoreSample"); + .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=EFCoreSample;ConnectRetryCount=0"); if (!_quiet) { diff --git a/samples/core/Miscellaneous/NewInEFCore6/TrailingUnderscoresSample.cs b/samples/core/Miscellaneous/NewInEFCore6/TrailingUnderscoresSample.cs index 6ab07bc8d7..ed730ca078 100644 --- a/samples/core/Miscellaneous/NewInEFCore6/TrailingUnderscoresSample.cs +++ b/samples/core/Miscellaneous/NewInEFCore6/TrailingUnderscoresSample.cs @@ -74,7 +74,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder .EnableSensitiveDataLogging() - .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=EFCoreSample"); + .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=EFCoreSample;ConnectRetryCount=0"); if (!_quiet) { diff --git a/samples/core/Miscellaneous/NewInEFCore6/UnicodeAttributeSample.cs b/samples/core/Miscellaneous/NewInEFCore6/UnicodeAttributeSample.cs index 41658176fd..a3648f8acb 100644 --- a/samples/core/Miscellaneous/NewInEFCore6/UnicodeAttributeSample.cs +++ b/samples/core/Miscellaneous/NewInEFCore6/UnicodeAttributeSample.cs @@ -69,7 +69,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder .EnableSensitiveDataLogging() - .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=EFCoreSample"); + .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=EFCoreSample;ConnectRetryCount=0"); if (!_quiet) { diff --git a/samples/core/Miscellaneous/NewInEFCore7/BlogsContext.cs b/samples/core/Miscellaneous/NewInEFCore7/BlogsContext.cs index a8baa0c521..64e04e5a06 100644 --- a/samples/core/Miscellaneous/NewInEFCore7/BlogsContext.cs +++ b/samples/core/Miscellaneous/NewInEFCore7/BlogsContext.cs @@ -185,7 +185,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => (UseSqlite ? optionsBuilder.UseSqlite(@$"DataSource={GetType().Name}.db") : optionsBuilder.UseSqlServer( - @$"Server=(localdb)\mssqllocaldb;Database={GetType().Name}", + @$"Server=(localdb)\mssqllocaldb;Database={GetType().Name};ConnectRetryCount=0", sqlServerOptionsBuilder => sqlServerOptionsBuilder.UseNetTopologySuite())) .EnableSensitiveDataLogging() .LogTo( diff --git a/samples/core/Miscellaneous/NewInEFCore7/DocumentsContext.cs b/samples/core/Miscellaneous/NewInEFCore7/DocumentsContext.cs index 5fda832e45..4b0127bffa 100644 --- a/samples/core/Miscellaneous/NewInEFCore7/DocumentsContext.cs +++ b/samples/core/Miscellaneous/NewInEFCore7/DocumentsContext.cs @@ -81,7 +81,7 @@ public abstract class DocumentsContext : DbContext public DbSet People => Set(); protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) - => optionsBuilder.UseSqlServer(@$"Server=(localdb)\mssqllocaldb;Database={GetType().Name}") + => optionsBuilder.UseSqlServer(@$"Server=(localdb)\mssqllocaldb;Database={GetType().Name};ConnectRetryCount=0") .EnableSensitiveDataLogging() .LogTo( s => diff --git a/samples/core/Miscellaneous/NewInEFCore7/GroupByEntityTypeSample.cs b/samples/core/Miscellaneous/NewInEFCore7/GroupByEntityTypeSample.cs index 31f9b4c48e..3b22c4ae7f 100644 --- a/samples/core/Miscellaneous/NewInEFCore7/GroupByEntityTypeSample.cs +++ b/samples/core/Miscellaneous/NewInEFCore7/GroupByEntityTypeSample.cs @@ -90,7 +90,7 @@ public class BookContextSqlServer : BookContext { protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => base.OnConfiguring( - optionsBuilder.UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=Books")); + optionsBuilder.UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=Books;ConnectRetryCount=0")); } public class BookContextSqlite : BookContext diff --git a/samples/core/Miscellaneous/NewInEFCore7/GroupByFinalOperatorSample.cs b/samples/core/Miscellaneous/NewInEFCore7/GroupByFinalOperatorSample.cs index 9afd5c7016..dafe9ba50e 100644 --- a/samples/core/Miscellaneous/NewInEFCore7/GroupByFinalOperatorSample.cs +++ b/samples/core/Miscellaneous/NewInEFCore7/GroupByFinalOperatorSample.cs @@ -75,7 +75,7 @@ public class BookContextSqlServer : BookContext { protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => base.OnConfiguring( - optionsBuilder.UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=Books")); + optionsBuilder.UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=Books;ConnectRetryCount=0")); } public class BookContextSqlite : BookContext diff --git a/samples/core/Miscellaneous/NewInEFCore7/GroupJoinFinalOperatorSample.cs b/samples/core/Miscellaneous/NewInEFCore7/GroupJoinFinalOperatorSample.cs index e81526c6a9..56bb973af2 100644 --- a/samples/core/Miscellaneous/NewInEFCore7/GroupJoinFinalOperatorSample.cs +++ b/samples/core/Miscellaneous/NewInEFCore7/GroupJoinFinalOperatorSample.cs @@ -104,7 +104,7 @@ public class GroupJoinContextSqlServer : GroupJoinContext { protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => base.OnConfiguring( - optionsBuilder.UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=Customers")); + optionsBuilder.UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=Customers;ConnectRetryCount=0")); } public class GroupJoinContextSqlite : GroupJoinContext diff --git a/samples/core/Miscellaneous/NewInEFCore7/ModelBuildingConventionsSample.cs b/samples/core/Miscellaneous/NewInEFCore7/ModelBuildingConventionsSample.cs index acf4fcf933..06a2a23681 100644 --- a/samples/core/Miscellaneous/NewInEFCore7/ModelBuildingConventionsSample.cs +++ b/samples/core/Miscellaneous/NewInEFCore7/ModelBuildingConventionsSample.cs @@ -259,7 +259,7 @@ public class LaundryContext : DbContext public DbSet LaundryBaskets => Set(); protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) - => optionsBuilder.UseSqlServer(@$"Server=(localdb)\mssqllocaldb;Database={GetType().Name}"); + => optionsBuilder.UseSqlServer(@$"Server=(localdb)\mssqllocaldb;Database={GetType().Name};ConnectRetryCount=0"); #region ReplaceConvention protected override void ConfigureConventions(ModelConfigurationBuilder configurationBuilder) @@ -386,7 +386,7 @@ public class TenantIdValidatingContext : DbContext public DbSet LaundryBaskets => Set(); protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) - => optionsBuilder.UseSqlServer(@$"Server=(localdb)\mssqllocaldb;Database={GetType().Name}"); + => optionsBuilder.UseSqlServer(@$"Server=(localdb)\mssqllocaldb;Database={GetType().Name};ConnectRetryCount=0"); protected override void ConfigureConventions(ModelConfigurationBuilder configurationBuilder) { diff --git a/samples/core/Miscellaneous/NewInEFCore7/ModelBuildingSample.cs b/samples/core/Miscellaneous/NewInEFCore7/ModelBuildingSample.cs index 979d833dcb..073b6420fc 100644 --- a/samples/core/Miscellaneous/NewInEFCore7/ModelBuildingSample.cs +++ b/samples/core/Miscellaneous/NewInEFCore7/ModelBuildingSample.cs @@ -305,7 +305,7 @@ public class BlogsContext : DbContext protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => optionsBuilder - .UseSqlServer(@$"Server=(localdb)\mssqllocaldb;Database=Blogs") + .UseSqlServer(@$"Server=(localdb)\mssqllocaldb;Database=Blogs;ConnectRetryCount=0") .LogTo(Console.WriteLine, LogLevel.Information) .EnableSensitiveDataLogging(); @@ -401,7 +401,7 @@ public class AnimalsTptContext : DbContext { protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => optionsBuilder - .UseSqlServer(@$"Server=(localdb)\mssqllocaldb;Database=AnimalsTpt") + .UseSqlServer(@$"Server=(localdb)\mssqllocaldb;Database=AnimalsTpt;ConnectRetryCount=0") .LogTo(Console.WriteLine, LogLevel.Information) .EnableSensitiveDataLogging(); @@ -427,7 +427,7 @@ public class AnimalsTpcContext : DbContext { protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => optionsBuilder - .UseSqlServer(@$"Server=(localdb)\mssqllocaldb;Database=AnimalsTpc") + .UseSqlServer(@$"Server=(localdb)\mssqllocaldb;Database=AnimalsTpc;ConnectRetryCount=0") .LogTo(Console.WriteLine, LogLevel.Information) .EnableSensitiveDataLogging(); @@ -485,7 +485,7 @@ public DbSet Employees protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => optionsBuilder - .UseSqlServer(@$"Server=(localdb)\mssqllocaldb;Database=Images") + .UseSqlServer(@$"Server=(localdb)\mssqllocaldb;Database=Images;ConnectRetryCount=0") .LogTo(Console.WriteLine, LogLevel.Information) .EnableSensitiveDataLogging(); diff --git a/samples/core/Miscellaneous/NewInEFCore7/QueryStatisticsLoggerSample.cs b/samples/core/Miscellaneous/NewInEFCore7/QueryStatisticsLoggerSample.cs index 0f31bb5839..d01287061a 100644 --- a/samples/core/Miscellaneous/NewInEFCore7/QueryStatisticsLoggerSample.cs +++ b/samples/core/Miscellaneous/NewInEFCore7/QueryStatisticsLoggerSample.cs @@ -15,7 +15,7 @@ public static async Task Executing_commands_after_consuming_a_result_set() var serviceProvider = new ServiceCollection() .AddDbContext( b => b.UseLoggerFactory(loggerFactory) - .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=ConsumedDataReaderSample")) + .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=ConsumedDataReaderSample;ConnectRetryCount=0")) .BuildServiceProvider(); using (var scope = serviceProvider.CreateScope()) diff --git a/samples/core/Miscellaneous/NewInEFCore7/ReadOnlySetQuerySample.cs b/samples/core/Miscellaneous/NewInEFCore7/ReadOnlySetQuerySample.cs index 1fba3603c7..7423cce829 100644 --- a/samples/core/Miscellaneous/NewInEFCore7/ReadOnlySetQuerySample.cs +++ b/samples/core/Miscellaneous/NewInEFCore7/ReadOnlySetQuerySample.cs @@ -114,7 +114,7 @@ public class ReadOnlySetContextSqlServer : ReadOnlySetContext { protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => base.OnConfiguring( - optionsBuilder.UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=Customers")); + optionsBuilder.UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=Customers;ConnectRetryCount=0")); } public class ReadOnlySetContextSqlite : ReadOnlySetContext diff --git a/samples/core/Miscellaneous/NewInEFCore7/SaveChangesPerformanceSample.cs b/samples/core/Miscellaneous/NewInEFCore7/SaveChangesPerformanceSample.cs index 467a0ce693..2daca432ff 100644 --- a/samples/core/Miscellaneous/NewInEFCore7/SaveChangesPerformanceSample.cs +++ b/samples/core/Miscellaneous/NewInEFCore7/SaveChangesPerformanceSample.cs @@ -147,7 +147,7 @@ public class PerfContextSqlServer : PerfContext { protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => base.OnConfiguring( - optionsBuilder.UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=SaveChangesPerf")); + optionsBuilder.UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=SaveChangesPerf;ConnectRetryCount=0")); } public class PerfContextSqlite : PerfContext diff --git a/samples/core/Miscellaneous/NewInEFCore7/StatisticalAggregateFunctionsSample.cs b/samples/core/Miscellaneous/NewInEFCore7/StatisticalAggregateFunctionsSample.cs index 4ff3b2139c..9bd247f1b7 100644 --- a/samples/core/Miscellaneous/NewInEFCore7/StatisticalAggregateFunctionsSample.cs +++ b/samples/core/Miscellaneous/NewInEFCore7/StatisticalAggregateFunctionsSample.cs @@ -60,7 +60,7 @@ public class StatisticsContext : DbContext protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => optionsBuilder - .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=Downloads") + .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=Downloads;ConnectRetryCount=0") .LogTo(Console.WriteLine, LogLevel.Information) .EnableSensitiveDataLogging(); } diff --git a/samples/core/Miscellaneous/NewInEFCore7/TpcInheritanceSample.cs b/samples/core/Miscellaneous/NewInEFCore7/TpcInheritanceSample.cs index e1e9288d39..ecebf60bd7 100644 --- a/samples/core/Miscellaneous/NewInEFCore7/TpcInheritanceSample.cs +++ b/samples/core/Miscellaneous/NewInEFCore7/TpcInheritanceSample.cs @@ -397,7 +397,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder .EnableSensitiveDataLogging() - .UseSqlServer(@$"Server=(localdb)\mssqllocaldb;Database={GetType().Name}"); + .UseSqlServer(@$"Server=(localdb)\mssqllocaldb;Database={GetType().Name};ConnectRetryCount=0"); optionsBuilder.LogTo(Console.WriteLine, LogLevel.Information); } diff --git a/samples/core/Miscellaneous/NewInEFCore7/UngroupedColumnsQuerySample.cs b/samples/core/Miscellaneous/NewInEFCore7/UngroupedColumnsQuerySample.cs index f5996fdb23..d81ff01d85 100644 --- a/samples/core/Miscellaneous/NewInEFCore7/UngroupedColumnsQuerySample.cs +++ b/samples/core/Miscellaneous/NewInEFCore7/UngroupedColumnsQuerySample.cs @@ -72,7 +72,7 @@ public class InvoiceContextSqlServer : InvoiceContext { protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => base.OnConfiguring( - optionsBuilder.UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=Invoices")); + optionsBuilder.UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=Invoices;ConnectRetryCount=0")); } public class InvoiceContextSqlite : InvoiceContext diff --git a/samples/core/Miscellaneous/NewInEFCore7/ValueGenerationSample.cs b/samples/core/Miscellaneous/NewInEFCore7/ValueGenerationSample.cs index b8afb2905d..64380bee68 100644 --- a/samples/core/Miscellaneous/NewInEFCore7/ValueGenerationSample.cs +++ b/samples/core/Miscellaneous/NewInEFCore7/ValueGenerationSample.cs @@ -47,7 +47,7 @@ public class ProductsContext : DbContext protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => optionsBuilder - .UseSqlServer(@$"Server=(localdb)\mssqllocaldb;Database=Products") + .UseSqlServer(@$"Server=(localdb)\mssqllocaldb;Database=Products;ConnectRetryCount=0") .LogTo(Console.WriteLine, LogLevel.Information) .EnableSensitiveDataLogging(); diff --git a/samples/core/Miscellaneous/NewInEFCore8/BlogsContext.cs b/samples/core/Miscellaneous/NewInEFCore8/BlogsContext.cs index c8a72ccc41..ebf2ce026d 100644 --- a/samples/core/Miscellaneous/NewInEFCore8/BlogsContext.cs +++ b/samples/core/Miscellaneous/NewInEFCore8/BlogsContext.cs @@ -210,7 +210,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => (UseSqlite ? optionsBuilder.UseSqlite(@$"DataSource={GetType().Name}.db") : optionsBuilder.UseSqlServer( - @$"Server=(localdb)\mssqllocaldb;Database={GetType().Name}", + @$"Server=(localdb)\mssqllocaldb;Database={GetType().Name};ConnectRetryCount=0", sqlServerOptionsBuilder => sqlServerOptionsBuilder.UseNetTopologySuite())) .EnableSensitiveDataLogging() .LogTo( diff --git a/samples/core/Miscellaneous/NewInEFCore8/ComplexTypesSample.cs b/samples/core/Miscellaneous/NewInEFCore8/ComplexTypesSample.cs index 885e532457..7f53c731b2 100644 --- a/samples/core/Miscellaneous/NewInEFCore8/ComplexTypesSample.cs +++ b/samples/core/Miscellaneous/NewInEFCore8/ComplexTypesSample.cs @@ -110,7 +110,7 @@ public abstract class CustomerContextBase(bool useSqlite = false) : DbContext protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => (UseSqlite ? optionsBuilder.UseSqlite(@$"DataSource={GetType().Name}.db") - : optionsBuilder.UseSqlServer(@$"Server=(localdb)\mssqllocaldb;Database={GetType().Name}")) + : optionsBuilder.UseSqlServer(@$"Server=(localdb)\mssqllocaldb;Database={GetType().Name};ConnectRetryCount=0")) .EnableSensitiveDataLogging() .LogTo( s => diff --git a/samples/core/Miscellaneous/NewInEFCore8/DateOnlyTimeOnlySample.cs b/samples/core/Miscellaneous/NewInEFCore8/DateOnlyTimeOnlySample.cs index d7a1b3edc0..8e5eae9baa 100644 --- a/samples/core/Miscellaneous/NewInEFCore8/DateOnlyTimeOnlySample.cs +++ b/samples/core/Miscellaneous/NewInEFCore8/DateOnlyTimeOnlySample.cs @@ -156,7 +156,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => (UseSqlite ? optionsBuilder.UseSqlite(@$"DataSource={GetType().Name}.db") : optionsBuilder.UseSqlServer( - @$"Server=(localdb)\mssqllocaldb;Database={GetType().Name}", + @$"Server=(localdb)\mssqllocaldb;Database={GetType().Name};ConnectRetryCount=0", sqlServerOptionsBuilder => sqlServerOptionsBuilder.UseNetTopologySuite())) .EnableSensitiveDataLogging() .LogTo( diff --git a/samples/core/Miscellaneous/NewInEFCore8/DefaultConstraintSample.cs b/samples/core/Miscellaneous/NewInEFCore8/DefaultConstraintSample.cs index f070317aa8..ca37df95f7 100644 --- a/samples/core/Miscellaneous/NewInEFCore8/DefaultConstraintSample.cs +++ b/samples/core/Miscellaneous/NewInEFCore8/DefaultConstraintSample.cs @@ -173,7 +173,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => (UseSqlite ? optionsBuilder.UseSqlite(@$"DataSource={GetType().Name}.db") : optionsBuilder.UseSqlServer( - @$"Server=(localdb)\mssqllocaldb;Database={GetType().Name}", + @$"Server=(localdb)\mssqllocaldb;Database={GetType().Name};ConnectRetryCount=0", sqlServerOptionsBuilder => sqlServerOptionsBuilder.UseNetTopologySuite())) .EnableSensitiveDataLogging() .LogTo(Console.WriteLine, LogLevel.Information); diff --git a/samples/core/Miscellaneous/NewInEFCore8/DocumentsContext.cs b/samples/core/Miscellaneous/NewInEFCore8/DocumentsContext.cs index 629f951356..80e72eefb3 100644 --- a/samples/core/Miscellaneous/NewInEFCore8/DocumentsContext.cs +++ b/samples/core/Miscellaneous/NewInEFCore8/DocumentsContext.cs @@ -80,7 +80,7 @@ public abstract class DocumentsContext : DbContext public DbSet People => Set(); protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) - => optionsBuilder.UseSqlServer(@$"Server=(localdb)\mssqllocaldb;Database={GetType().Name}") + => optionsBuilder.UseSqlServer(@$"Server=(localdb)\mssqllocaldb;Database={GetType().Name};ConnectRetryCount=0") .EnableSensitiveDataLogging() .LogTo( s => diff --git a/samples/core/Miscellaneous/NewInEFCore8/ExecuteUpdateDeleteSample.cs b/samples/core/Miscellaneous/NewInEFCore8/ExecuteUpdateDeleteSample.cs index 8957425a1f..b668184b6a 100644 --- a/samples/core/Miscellaneous/NewInEFCore8/ExecuteUpdateDeleteSample.cs +++ b/samples/core/Miscellaneous/NewInEFCore8/ExecuteUpdateDeleteSample.cs @@ -157,7 +157,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => (UseSqlite ? optionsBuilder.UseSqlite(@$"DataSource={GetType().Name}.db") : optionsBuilder.UseSqlServer( - @$"Server=(localdb)\mssqllocaldb;Database={GetType().Name}", + @$"Server=(localdb)\mssqllocaldb;Database={GetType().Name};ConnectRetryCount=0", sqlServerOptionsBuilder => sqlServerOptionsBuilder.UseNetTopologySuite())) .EnableSensitiveDataLogging() .LogTo(Console.WriteLine, LogLevel.Information); diff --git a/samples/core/Miscellaneous/NewInEFCore8/HierarchyIdSample.cs b/samples/core/Miscellaneous/NewInEFCore8/HierarchyIdSample.cs index 2769b9f85a..f319ce386e 100644 --- a/samples/core/Miscellaneous/NewInEFCore8/HierarchyIdSample.cs +++ b/samples/core/Miscellaneous/NewInEFCore8/HierarchyIdSample.cs @@ -230,7 +230,7 @@ public class FamilyTreeContext : DbContext protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => optionsBuilder.UseSqlServer( - @$"Server=(localdb)\mssqllocaldb;Database={GetType().Name}", + @$"Server=(localdb)\mssqllocaldb;Database={GetType().Name};ConnectRetryCount=0", sqlServerOptionsBuilder => sqlServerOptionsBuilder.UseHierarchyId()) .EnableSensitiveDataLogging() .LogTo( diff --git a/samples/core/Miscellaneous/NewInEFCore8/ImmutableComplexTypesSample.cs b/samples/core/Miscellaneous/NewInEFCore8/ImmutableComplexTypesSample.cs index 2f113f4fa6..2b43a775dc 100644 --- a/samples/core/Miscellaneous/NewInEFCore8/ImmutableComplexTypesSample.cs +++ b/samples/core/Miscellaneous/NewInEFCore8/ImmutableComplexTypesSample.cs @@ -100,7 +100,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => (UseSqlite ? optionsBuilder.UseSqlite(@$"DataSource={GetType().Name}.db") : optionsBuilder.UseSqlServer( - @$"Server=(localdb)\mssqllocaldb;Database={GetType().Name}")) + @$"Server=(localdb)\mssqllocaldb;Database={GetType().Name};ConnectRetryCount=0")) //sqlServerOptionsBuilder => sqlServerOptionsBuilder.UseCompatibilityLevel(120))) .EnableSensitiveDataLogging() .LogTo( diff --git a/samples/core/Miscellaneous/NewInEFCore8/ImmutableStructComplexTypesSample.cs b/samples/core/Miscellaneous/NewInEFCore8/ImmutableStructComplexTypesSample.cs index b5987b86da..8bfb3ed97b 100644 --- a/samples/core/Miscellaneous/NewInEFCore8/ImmutableStructComplexTypesSample.cs +++ b/samples/core/Miscellaneous/NewInEFCore8/ImmutableStructComplexTypesSample.cs @@ -106,7 +106,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => (UseSqlite ? optionsBuilder.UseSqlite(@$"DataSource={GetType().Name}.db") : optionsBuilder.UseSqlServer( - @$"Server=(localdb)\mssqllocaldb;Database={GetType().Name}")) + @$"Server=(localdb)\mssqllocaldb;Database={GetType().Name};ConnectRetryCount=0")) //sqlServerOptionsBuilder => sqlServerOptionsBuilder.UseCompatibilityLevel(120))) .EnableSensitiveDataLogging() .LogTo( diff --git a/samples/core/Miscellaneous/NewInEFCore8/NestedComplexTypesSample.cs b/samples/core/Miscellaneous/NewInEFCore8/NestedComplexTypesSample.cs index 5b71bafe06..ed49aadd21 100644 --- a/samples/core/Miscellaneous/NewInEFCore8/NestedComplexTypesSample.cs +++ b/samples/core/Miscellaneous/NewInEFCore8/NestedComplexTypesSample.cs @@ -206,7 +206,7 @@ public abstract class CustomerContextBase(bool useSqlite = false) : DbContext protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => (UseSqlite ? optionsBuilder.UseSqlite(@$"DataSource={GetType().Name}.db") - : optionsBuilder.UseSqlServer(@$"Server=(localdb)\mssqllocaldb;Database={GetType().Name}")) + : optionsBuilder.UseSqlServer(@$"Server=(localdb)\mssqllocaldb;Database={GetType().Name};ConnectRetryCount=0")) .EnableSensitiveDataLogging() .LogTo( s => diff --git a/samples/core/Miscellaneous/NewInEFCore8/PrimitiveCollectionToTableSample.cs b/samples/core/Miscellaneous/NewInEFCore8/PrimitiveCollectionToTableSample.cs index 29d4eb3ea2..ede3b7e5d1 100644 --- a/samples/core/Miscellaneous/NewInEFCore8/PrimitiveCollectionToTableSample.cs +++ b/samples/core/Miscellaneous/NewInEFCore8/PrimitiveCollectionToTableSample.cs @@ -108,7 +108,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => (UseSqlite ? optionsBuilder.UseSqlite(@$"DataSource={GetType().Name}.db") : optionsBuilder.UseSqlServer( - @$"Server=(localdb)\mssqllocaldb;Database={GetType().Name}")) + @$"Server=(localdb)\mssqllocaldb;Database={GetType().Name};ConnectRetryCount=0")) .EnableSensitiveDataLogging() .LogTo( s => diff --git a/samples/core/Miscellaneous/NewInEFCore8/PrimitiveCollectionsInJsonSample.cs b/samples/core/Miscellaneous/NewInEFCore8/PrimitiveCollectionsInJsonSample.cs index 986785287c..042ac034b8 100644 --- a/samples/core/Miscellaneous/NewInEFCore8/PrimitiveCollectionsInJsonSample.cs +++ b/samples/core/Miscellaneous/NewInEFCore8/PrimitiveCollectionsInJsonSample.cs @@ -190,7 +190,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => (UseSqlite ? optionsBuilder.UseSqlite(@$"DataSource={GetType().Name}.db") : optionsBuilder.UseSqlServer( - @$"Server=(localdb)\mssqllocaldb;Database={GetType().Name}")) + @$"Server=(localdb)\mssqllocaldb;Database={GetType().Name};ConnectRetryCount=0")) //sqlServerOptionsBuilder => sqlServerOptionsBuilder.UseCompatibilityLevel(120))) .EnableSensitiveDataLogging() .LogTo( diff --git a/samples/core/Miscellaneous/NewInEFCore8/PrimitiveCollectionsSample.cs b/samples/core/Miscellaneous/NewInEFCore8/PrimitiveCollectionsSample.cs index 61dbac5a5e..ffdd96204b 100644 --- a/samples/core/Miscellaneous/NewInEFCore8/PrimitiveCollectionsSample.cs +++ b/samples/core/Miscellaneous/NewInEFCore8/PrimitiveCollectionsSample.cs @@ -248,7 +248,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => (UseSqlite ? optionsBuilder.UseSqlite(@$"DataSource={GetType().Name}.db") : optionsBuilder.UseSqlServer( - @$"Server=(localdb)\mssqllocaldb;Database={GetType().Name}")) + @$"Server=(localdb)\mssqllocaldb;Database={GetType().Name};ConnectRetryCount=0")) //sqlServerOptionsBuilder => sqlServerOptionsBuilder.UseCompatibilityLevel(120))) .EnableSensitiveDataLogging() .LogTo( diff --git a/samples/core/Miscellaneous/NewInEFCore8/RecordComplexTypesSample.cs b/samples/core/Miscellaneous/NewInEFCore8/RecordComplexTypesSample.cs index a779f32d92..d495f148dc 100644 --- a/samples/core/Miscellaneous/NewInEFCore8/RecordComplexTypesSample.cs +++ b/samples/core/Miscellaneous/NewInEFCore8/RecordComplexTypesSample.cs @@ -93,7 +93,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => (UseSqlite ? optionsBuilder.UseSqlite(@$"DataSource={GetType().Name}.db") : optionsBuilder.UseSqlServer( - @$"Server=(localdb)\mssqllocaldb;Database={GetType().Name}")) + @$"Server=(localdb)\mssqllocaldb;Database={GetType().Name};ConnectRetryCount=0")) //sqlServerOptionsBuilder => sqlServerOptionsBuilder.UseCompatibilityLevel(120))) .EnableSensitiveDataLogging() .LogTo( @@ -245,7 +245,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => (UseSqlite ? optionsBuilder.UseSqlite(@$"DataSource={GetType().Name}.db") : optionsBuilder.UseSqlServer( - @$"Server=(localdb)\mssqllocaldb;Database={GetType().Name}")) + @$"Server=(localdb)\mssqllocaldb;Database={GetType().Name};ConnectRetryCount=0")) //sqlServerOptionsBuilder => sqlServerOptionsBuilder.UseCompatibilityLevel(120))) .EnableSensitiveDataLogging() .LogTo( diff --git a/samples/core/Miscellaneous/NewInEFCore8/StructComplexTypesSample.cs b/samples/core/Miscellaneous/NewInEFCore8/StructComplexTypesSample.cs index c117f56d4b..8380456fcb 100644 --- a/samples/core/Miscellaneous/NewInEFCore8/StructComplexTypesSample.cs +++ b/samples/core/Miscellaneous/NewInEFCore8/StructComplexTypesSample.cs @@ -107,7 +107,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => (UseSqlite ? optionsBuilder.UseSqlite(@$"DataSource={GetType().Name}.db") : optionsBuilder.UseSqlServer( - @$"Server=(localdb)\mssqllocaldb;Database={GetType().Name}")) + @$"Server=(localdb)\mssqllocaldb;Database={GetType().Name};ConnectRetryCount=0")) //sqlServerOptionsBuilder => sqlServerOptionsBuilder.UseCompatibilityLevel(120))) .EnableSensitiveDataLogging() .LogTo( diff --git a/samples/core/Miscellaneous/NewInEFCore9.CompiledModels/App/App.csproj b/samples/core/Miscellaneous/NewInEFCore9.CompiledModels/App/App.csproj index 20df067599..fe513d3fc4 100644 --- a/samples/core/Miscellaneous/NewInEFCore9.CompiledModels/App/App.csproj +++ b/samples/core/Miscellaneous/NewInEFCore9.CompiledModels/App/App.csproj @@ -9,7 +9,7 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/samples/core/Miscellaneous/NewInEFCore9.CompiledModels/Model/Model.csproj b/samples/core/Miscellaneous/NewInEFCore9.CompiledModels/Model/Model.csproj index 92369134bc..2af439d9d3 100644 --- a/samples/core/Miscellaneous/NewInEFCore9.CompiledModels/Model/Model.csproj +++ b/samples/core/Miscellaneous/NewInEFCore9.CompiledModels/Model/Model.csproj @@ -15,13 +15,13 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive all - - - + + + diff --git a/samples/core/Miscellaneous/NewInEFCore9.Cosmos/CosmosPrimitiveTypesSample.cs b/samples/core/Miscellaneous/NewInEFCore9.Cosmos/CosmosPrimitiveTypesSample.cs new file mode 100644 index 0000000000..37c3a4bd7d --- /dev/null +++ b/samples/core/Miscellaneous/NewInEFCore9.Cosmos/CosmosPrimitiveTypesSample.cs @@ -0,0 +1,116 @@ +using System; +using System.Collections.Generic; +using System.Net.Http; +using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Diagnostics; + +public static class CosmosPrimitiveTypesSample +{ + public static async Task Collections_and_dictionaries_of_primitive_types() + { + Console.WriteLine($">>>> Sample: {nameof(Collections_and_dictionaries_of_primitive_types)}"); + Console.WriteLine(); + + await Helpers.RecreateCleanDatabase(); + + using var context = new BooksContext(); + + var book = new Book + { + Title = "How It Works: Incredible History", + Quotes = new List + { + "Thomas (Tommy) Flowers was the British engineer behind the design of the Colossus computer.", + "Invented originally for Guinness, plastic widgets are nitrogen-filled spheres.", + "For 20 years after its introduction in 1979, the Walkman dominated the personal stereo market." + }, + Notes = new Dictionary + { + { "121", "Fridges" }, + { "144", "Peter Higgs" }, + { "48", "Saint Mark's Basilica" }, + { "36", "The Terracotta Army" } + } + }; + + context.Add(book); + await context.SaveChangesAsync(); + + book.Quotes.Add("Pressing the emergency button lowered the rods again."); + book.Notes["48"] = "Chiesa d'Oro"; + + await context.SaveChangesAsync(); + + Console.WriteLine(); + } + + public static class Helpers + { + public static async Task RecreateCleanDatabase() + { + await using var context = new BooksContext(quiet: true); + + await context.Database.EnsureDeletedAsync(); + await context.Database.EnsureCreatedAsync(); + } + } + + public class Book + { + public Guid Id { get; set; } + public string Title { get; set; } + public IList Quotes { get; set; } + public IDictionary Notes { get; set; } + } + + public class BooksContext : DbContext + { + public DbSet Books { get; set; } + + private readonly bool _quiet; + + public BooksContext(bool quiet = false) + { + _quiet = quiet; + } + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.Entity().ToContainer("Shapes"); + + #region ConfigureCollection + modelBuilder.Entity() + .PrimitiveCollection(e => e.Quotes) + .ElementType(b => b.IsRequired()); + #endregion + } + + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) + { + optionsBuilder + .EnableSensitiveDataLogging() + .UseCosmos( + "https://localhost:8081", + "C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==", + "PrimitiveCollections", + cosmosOptionsBuilder => + { + cosmosOptionsBuilder.HttpClientFactory( + () => new HttpClient( + new HttpClientHandler + { + ServerCertificateCustomValidationCallback = + HttpClientHandler.DangerousAcceptAnyServerCertificateValidator + })); + }); + + if (!_quiet) + { + optionsBuilder.LogTo( + Console.WriteLine, + new[] { CosmosEventId.ExecutedCreateItem, CosmosEventId.ExecutingSqlQuery, CoreEventId.SaveChangesCompleted }); + } + } + } +} diff --git a/samples/core/Miscellaneous/NewInEFCore9.Cosmos/CosmosSyncApisSample.cs b/samples/core/Miscellaneous/NewInEFCore9.Cosmos/CosmosSyncApisSample.cs new file mode 100644 index 0000000000..0c90397a22 --- /dev/null +++ b/samples/core/Miscellaneous/NewInEFCore9.Cosmos/CosmosSyncApisSample.cs @@ -0,0 +1,105 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Diagnostics; +using Microsoft.Extensions.Logging; + +public static class CosmosSyncApisSample +{ + public static void Cosmos_provider_blocks_sync_APIs() + { + Console.WriteLine($">>>> Sample: {nameof(Cosmos_provider_blocks_sync_APIs)}"); + Console.WriteLine(); + + Helpers.RecreateCleanDatabase(); + Helpers.PopulateDatabase(); + + using var context = new ShapesContext(); + + var triangle = new Triangle + { + Name = "Impossible", + PartitionKey = "TrianglesPartition", + Angle1 = 90, + Angle2 = 90, + InsertedOn = DateTime.UtcNow + }; + context.Add(triangle); + context.SaveChanges(); + + var equilateral = context.Triangles.Single(e => e.Name == "Equilateral"); + var isosceles = context.Triangles.Find("Isosceles", "TrianglesPartition"); + + triangle.Angle2 = 89; + context.SaveChanges(); + + context.Remove(triangle); + context.SaveChanges(); + } + + public static class Helpers + { + public static void RecreateCleanDatabase() + { + using var context = new ShapesContext(quiet: true); + + context.Database.EnsureDeleted(); + context.Database.EnsureCreated(); + } + + public static void PopulateDatabase() + { + using var context = new ShapesContext(quiet: true); + + var triangles = new List + { + new() { Name = "Acute", PartitionKey = "TrianglesPartition", Angle1 = 75, Angle2 = 85, InsertedOn = DateTime.UtcNow }, + new() { Name = " Obtuse ", PartitionKey = "TrianglesPartition", Angle1 = 110, Angle2 = 35, InsertedOn = DateTime.UtcNow }, + new() { Name = "Right", PartitionKey = "TrianglesPartition", Angle1 = 90, Angle2 = 45, InsertedOn = DateTime.UtcNow }, + new() { Name = "Isosceles", PartitionKey = "TrianglesPartition", Angle1 = 75, Angle2 = 75, InsertedOn = DateTime.UtcNow }, + new() { Name = "Equilateral", PartitionKey = "TrianglesPartition", Angle1 = 60, Angle2 = 60, InsertedOn = DateTime.UtcNow } + }; + + context.AddRange(triangles); + context.SaveChanges(); + } + } + + public class Triangle + { + public string PartitionKey { get; set; } + public string Name { get; set; } + public double Angle1 { get; set; } + public double Angle2 { get; set; } + public DateTime InsertedOn { get; set; } + } + + public class ShapesContext(bool quiet = false) : DbContext + { + public DbSet Triangles { get; set; } + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.Entity( + b => + { + b.ToContainer("Shapes"); + b.HasPartitionKey(e => e.PartitionKey); + b.HasKey(e => new { e.Name, e.PartitionKey }); + b.Property(c => c.Name).ToJsonProperty("id"); + b.Property(c => c.PartitionKey).ToJsonProperty("pk"); + }); + } + + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) + => optionsBuilder + .ConfigureWarnings(b => b.Log(CosmosEventId.SyncNotSupported)) + .LogTo(Console.WriteLine, LogLevel.Information) + .EnableSensitiveDataLogging() + .UseCosmos( + "https://localhost:8081", + "C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==", + "Triangles"); + } +} diff --git a/samples/core/Miscellaneous/NewInEFCore9.Cosmos/NewInEFCore9.Cosmos.csproj b/samples/core/Miscellaneous/NewInEFCore9.Cosmos/NewInEFCore9.Cosmos.csproj new file mode 100644 index 0000000000..ba4fe7e8f0 --- /dev/null +++ b/samples/core/Miscellaneous/NewInEFCore9.Cosmos/NewInEFCore9.Cosmos.csproj @@ -0,0 +1,13 @@ + + + + Exe + net8.0 + + + + + + + + diff --git a/samples/core/Miscellaneous/NewInEFCore9.Cosmos/Program.cs b/samples/core/Miscellaneous/NewInEFCore9.Cosmos/Program.cs new file mode 100644 index 0000000000..dacbe2028a --- /dev/null +++ b/samples/core/Miscellaneous/NewInEFCore9.Cosmos/Program.cs @@ -0,0 +1,11 @@ +using System.Threading.Tasks; + +public class Program +{ + public static async Task Main() + { + // Note: These samples requires the Cosmos DB emulator to be installed and running + CosmosSyncApisSample.Cosmos_provider_blocks_sync_APIs(); + await CosmosPrimitiveTypesSample.Collections_and_dictionaries_of_primitive_types(); + } +} diff --git a/samples/core/Miscellaneous/NewInEFCore9/ComplexTypesSample.cs b/samples/core/Miscellaneous/NewInEFCore9/ComplexTypesSample.cs new file mode 100644 index 0000000000..3ced347a37 --- /dev/null +++ b/samples/core/Miscellaneous/NewInEFCore9/ComplexTypesSample.cs @@ -0,0 +1,148 @@ +namespace NewInEfCore9; + +public static class ComplexTypesSample +{ + public static Task GropupBy_complex_type_instances() + => ExecuteQueries(sqlite: false); + + public static Task GropupBy_complex_type_instances_on_SQLite() + => ExecuteQueries(sqlite: true); + + public static async Task ExecuteQueries(bool sqlite) + { + PrintSampleName(); + + await using var context = new CustomerContext(useSqlite: sqlite); + await context.Database.EnsureDeletedAsync(); + await context.Database.EnsureCreatedAsync(); + + context.AddRange( + new Store + { + Customers = { new CustomerWithStores { Name = "Smokey", Region = "Germany" } }, + Region = "Germany", + StoreAddress = new("L1", null, "Ci1", "Co1", "P1") + }, + new Customer + { + Name = "Smokey", + CustomerInfo = new("EF") + { + HomeAddress = new("L2", null, "Ci2", "Co2", "P2"), WorkAddress = new("L3", null, "Ci3", "Co3", "P3") + }, + }, + new CustomerTpt + { + Name = "Willow", + CustomerInfo = new("EF") + { + HomeAddress = new("L5", null, "Ci5", "Co5", "P5"), WorkAddress = new("L6", null, "Ci6", "Co6", "P6") + }, + }, + new SpecialCustomerTpt + { + Name = "Olive", + CustomerInfo = new("EF") + { + HomeAddress = new("L7", null, "Ci7", "Co7", "P7"), WorkAddress = new("L8", null, "Ci8", "Co8", "P8") + } + }); + + await context.SaveChangesAsync(); + context.ChangeTracker.Clear(); + + Console.WriteLine(); + Console.WriteLine("GroupBy complex type:"); + Console.WriteLine(); + + #region GroupByComplexType + var groupedAddresses = await context.Stores + .GroupBy(b => b.StoreAddress) + .Select(g => new { g.Key, Count = g.Count() }) + .ToListAsync(); + #endregion + + foreach (var groupedAddress in groupedAddresses) + { + Console.WriteLine($"{groupedAddress.Key.PostCode}: {groupedAddress.Count}"); + } + } + + private static void PrintSampleName([CallerMemberName] string? methodName = null) + { + Console.WriteLine($">>>> Sample: {methodName}"); + Console.WriteLine(); + } + + [Table("TptSpecialCustomers")] + public class SpecialCustomerTpt : CustomerTpt + { + public string? Note { get; set; } + } + + [Table("TptCustomers")] + public class CustomerTpt + { + public int Id { get; set; } + public required string Name { get; set; } + public required CustomerInfo CustomerInfo { get; set; } + } + + public class Customer + { + public int Id { get; set; } + public required string Name { get; set; } + public required CustomerInfo CustomerInfo { get; set; } + } + + public record struct CustomerInfo(string? Tag) + { + public required Address HomeAddress { get; init; } + public required Address WorkAddress { get; init; } + } + + [ComplexType] + public record class Address(string Line1, string? Line2, string City, string Country, string PostCode); + + public class CustomerWithStores + { + public int Id { get; set; } + public required string Name { get; set; } + public string? Region { get; set; } + public string? Tag { get; set; } + } + + public class Store + { + public int Id { get; set; } + public List Customers { get; } = new(); + public string? Region { get; set; } + public required Address StoreAddress { get; set; } + } + + public class CustomerContext(bool useSqlite = false) : DbContext + { + public bool UseSqlite { get; } = useSqlite; + + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) + => (UseSqlite + ? optionsBuilder.UseSqlite(@$"DataSource={GetType().Name}.db", + sqliteOptionsBuilder => sqliteOptionsBuilder.UseNetTopologySuite()) + : optionsBuilder.UseSqlServer( + @$"Server=(localdb)\mssqllocaldb;Database={GetType().Name};ConnectRetryCount=0", + sqlServerOptionsBuilder => sqlServerOptionsBuilder.UseNetTopologySuite())) + .EnableSensitiveDataLogging() + .LogTo(Console.WriteLine, LogLevel.Information); + + protected override void ConfigureConventions(ModelConfigurationBuilder configurationBuilder) + { + configurationBuilder.ComplexProperties(); + } + + public DbSet Customers => Set(); + public DbSet CustomersWithStores => Set(); + public DbSet Stores => Set(); + public DbSet TptCustomers => Set(); + public DbSet TptSpecialCustomers => Set(); + } +} diff --git a/samples/core/Miscellaneous/NewInEFCore9/NewInEFCore9.csproj b/samples/core/Miscellaneous/NewInEFCore9/NewInEFCore9.csproj index 45bacb8f74..1f4c24d2a1 100644 --- a/samples/core/Miscellaneous/NewInEFCore9/NewInEFCore9.csproj +++ b/samples/core/Miscellaneous/NewInEFCore9/NewInEFCore9.csproj @@ -10,15 +10,15 @@ - - - - - - - - - + + + + + + + + + diff --git a/samples/core/Miscellaneous/NewInEFCore9/PrimitiveCollectionsSample.cs b/samples/core/Miscellaneous/NewInEFCore9/PrimitiveCollectionsSample.cs new file mode 100644 index 0000000000..c050e002e3 --- /dev/null +++ b/samples/core/Miscellaneous/NewInEFCore9/PrimitiveCollectionsSample.cs @@ -0,0 +1,509 @@ +using System.Collections; +using System.Collections.ObjectModel; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +namespace NewInEfCore9; + +public static class PrimitiveCollectionsSample +{ + public static Task Queries_using_readonly_primitive_collections() + { + PrintSampleName(); + return ContainsTest(); + } + + public static Task Queries_using_readonly_primitive_collections_SQLite() + { + PrintSampleName(); + return ContainsTest(); + } + + private static async Task ContainsTest() + where TContext : PubsAndWalksContextBase, new() + { + await using var context = new TContext(); + await context.Database.EnsureDeletedAsync(); + await context.Database.EnsureCreatedAsync(); + await context.Seed(); + + context.LoggingEnabled = true; + context.ChangeTracker.Clear(); + + var terrains = new[] { Terrain.River, Terrain.Beach, Terrain.Park }; + var walksWithTerrain = await context.Walks + .Where(e => terrains.Contains(e.Terrain)) + .Select(e => e.Name) + .ToListAsync(); + + Console.WriteLine($"\nWalks with given terrain are {string.Join(", ", walksWithTerrain.Select(w => $"\"{w}\""))}"); + + var beer = "Heineken"; + var pubsWithHeineken = await context.Pubs + .Where(e => e.Beers.Contains(beer)) + .Select(e => e.Name) + .ToListAsync(); + + Console.WriteLine($"\nPubs with {beer} are {string.Join(", ", pubsWithHeineken)}"); + + var beers = new[] { "Carling", "Heineken", "Stella Artois", "Carlsberg" }; + var pubsWithLager = await context.Pubs + .Where(e => beers.Any(b => e.Beers.Contains(b))) + .Select(e => e.Name) + .ToListAsync(); + + Console.WriteLine($"\nPubs with lager are {string.Join(", ", pubsWithLager)}"); + + var thisYear = DateTime.Now.Year; + var pubsVisitedThisYear = await context.Pubs + .Where(e => e.DaysVisited.Any(v => v.Year == thisYear)) + .Select(e => e.Name) + .ToListAsync(); + + Console.WriteLine($"\nPubs visited this year are {string.Join(", ", pubsVisitedThisYear)}"); + + var pubsVisitedInOrder = await context.Pubs + .Select( + e => new + { + e.Name, + FirstVisited = e.DaysVisited.OrderBy(v => v).First(), + LastVisited = e.DaysVisited.OrderByDescending(v => v).First(), + }) + .OrderBy(p => p.FirstVisited) + .ToListAsync(); + + foreach (var pub in pubsVisitedInOrder) + { + Console.WriteLine($"{pub.Name} first visited on {pub.FirstVisited} and last visited on {pub.LastVisited}"); + } + + #region WalksWithADrink + var walksWithADrink = await context.Walks.Select( + w => new + { + WalkName = w.Name, + PubName = w.ClosestPub.Name, + Count = w.DaysVisited.Count(v => w.ClosestPub.DaysVisited.Contains(v)), + TotalCount = w.DaysVisited.Count + }).ToListAsync(); + #endregion + + Console.WriteLine(); + foreach (var walk in walksWithADrink) + { + Console.WriteLine($"{walk.PubName} was visited {walk.Count} times in {walk.TotalCount} \"{walk.WalkName}\" walks."); + } + } + + private static void PrintSampleName([CallerMemberName] string? methodName = null) + { + Console.WriteLine($">>>> Sample: {methodName}"); + Console.WriteLine(); + } + + public class MyCollection : IList + { + private readonly List _list = new(); + public IEnumerator GetEnumerator() => _list.GetEnumerator(); + IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); + public void Add(int item) => _list.Add(item); + public void Clear() => _list.Clear(); + public bool Contains(int item) => _list.Contains(item); + public void CopyTo(int[] array, int arrayIndex) => _list.CopyTo(array, arrayIndex); + public bool Remove(int item) => _list.Remove(item); + public int Count => _list.Count; + public bool IsReadOnly => ((ICollection)_list).IsReadOnly; + public int IndexOf(int item) => _list.IndexOf(item); + public void Insert(int index, int item) => _list.Insert(index, item); + public void RemoveAt(int index) => _list.RemoveAt(index); + + public int this[int index] + { + get => _list[index]; + set => _list[index] = value; + } + } + + public class PrimitiveCollections + { + public int Id { get; set; } + public IReadOnlyList Ints { get; set; } = null!; + public IReadOnlyCollection Strings { get; set; } = null!; + public ReadOnlyCollection DateTimes { get; set; } = null!; + public IList Dates { get; set; } = null!; + + [MaxLength(2500)] + [Unicode(false)] + public uint[] UnsignedInts { get; set; } = null!; + + public ObservableCollection Guids { get; set; } = null!; + public List Booleans { get; set; } = null!; + public List Urls { get; set; } = null!; + public MyCollection SomeInts { get; set; } = null!; + public List GetOnlyInts { get; } = new(); + + // ReSharper disable once CollectionNeverUpdated.Local + private readonly List _intsField = new(); + + public List DddIds { get; set; } = null!; + } + + public readonly struct DddId + { + public DddId(int value) + { + Value = value; + } + + public int Value { get; } + } + + public class DddIdConverter : ValueConverter + { + public DddIdConverter() + : base(v => v.Value, v => new DddId()) + { + } + } + + public class DogWalk + { + public DogWalk(string name) + { + Name = name; + } + + public int Id { get; set; } + public string Name { get; set; } + public Terrain Terrain { get; set; } + public ReadOnlyCollection DaysVisited { get; set; } + public Pub ClosestPub { get; set; } = null!; + } + + public enum Terrain + { + Forest, + River, + Hills, + Village, + Park, + Beach, + } + + public class Pub + { + public Pub(string name, IReadOnlyCollection beers) + { + Name = name; + Beers = beers; + } + + public int Id { get; set; } + public string Name { get; set; } + public IReadOnlyCollection Beers { get; set; } + + private List _daysVisited = new(); + public IReadOnlyList DaysVisited => _daysVisited; + } + + public class PubsAndWalksContext : PubsAndWalksContextBase + { + } + + public class PubsAndWalksContextSqlite : PubsAndWalksContextBase + { + public PubsAndWalksContextSqlite() + : base(useSqlite: true) + { + } + } + + public abstract class PubsAndWalksContextBase : DbContext + { + protected PubsAndWalksContextBase(bool useSqlite = false) + { + UseSqlite = useSqlite; + } + + public bool UseSqlite { get; } + public bool LoggingEnabled { get; set; } + + public DbSet Walks => Set(); + public DbSet Pubs => Set(); + + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) + => (UseSqlite + ? optionsBuilder.UseSqlite(@$"DataSource={GetType().Name}.db") + : optionsBuilder.UseSqlServer( + @$"Server=(localdb)\mssqllocaldb;Database={GetType().Name};ConnectRetryCount=0")) + //sqlServerOptionsBuilder => sqlServerOptionsBuilder.UseCompatibilityLevel(120))) + .EnableSensitiveDataLogging() + .LogTo( + s => + { + if (LoggingEnabled) + { + Console.WriteLine(s); + } + }, LogLevel.Information); + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder + .Entity() + .PrimitiveCollection(e => e.Booleans) + .HasMaxLength(1024) + .IsUnicode(false); + + modelBuilder + .Entity() + .PrimitiveCollection(e => e.Guids) + .HasColumnType("nvarchar(2000)"); + + modelBuilder + .Entity() + .PrimitiveCollection(e => e.GetOnlyInts); + + modelBuilder + .Entity() + .PrimitiveCollection(e => e.DddIds) + .ElementType(b => b.HasConversion()); + + modelBuilder + .Entity() + .Property>("_intsField"); + + modelBuilder.Entity().Property(e => e.Terrain).HasConversion(); + modelBuilder.Entity().PrimitiveCollection(e => e.DaysVisited); + } + + protected override void ConfigureConventions(ModelConfigurationBuilder configurationBuilder) + { + configurationBuilder + .Properties>() + .AreUnicode(false) + .HaveMaxLength(4000); + + configurationBuilder + .Properties() + .HaveMaxLength(2000); + + configurationBuilder + .DefaultTypeMapping() + .HasConversion(); + } + + public async Task Seed() + { + Add( + new PrimitiveCollections + { + Ints = new[] { 1, 2, 3 }, + Strings = new List { "One", "Two", "Three" }, + DateTimes = + new ReadOnlyCollection([new(2023, 1, 1, 1, 1, 1), new(2023, 2, 2, 2, 2, 2), new(2023, 3, 3, 3, 3, 3)]), + Dates = new List { new(2023, 1, 1), new(2023, 2, 2), new(2023, 3, 3) }, + UnsignedInts = new uint[] { 1, 2, 3 }, + Guids = new() { Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid() }, + Booleans = new() { true, false, true }, + Urls = new() { new("https://127.0.0.1/"), new("http://192.168.0.1/"), new("https://devblogs.microsoft.com/dotnet/") }, + SomeInts = new() { 1, 2, 3 }, + DddIds = new() { new(1), new(2), new(3) } + }); + + var oak = new Pub("The Royal Oak", new[] { "Oakham", "Carling", "Guinness", "John Smiths", "Bathams", "Tennents" }); + ((List)oak.DaysVisited).AddRange( + [ + new(2021, 1, 2), + new(2021, 8, 7), + new(2023, 3, 22), + new(2022, 4, 22), + new(2022, 7, 21), + new(2022, 6, 21), + ]); + + var feathers = new Pub("The Prince of Wales Feathers", new[] { "Heineken", "John Smiths", "Stella Artois", "Carlsberg" }); + ((List)feathers.DaysVisited).AddRange( + [ + new(2022, 11, 17), + new(2021, 9, 25), + new(2022, 12, 21), + new(2022, 11, 7), + new(2022, 8, 9), + new(2022, 3, 10), + new(2021, 12, 1), + new(2022, 3, 8), + new(2022, 2, 28), + new(2021, 5, 10), + new(2021, 6, 25), + ]); + + var swan = new Pub( + "The White Swan", new[] { "Oakham", "Carling", "Guinness", "Heineken", "Stella Artois", "Carlsberg", "Bathams" }); + ((List)swan.DaysVisited).AddRange( + [ + new(2021, 2, 24), + new(2022, 8, 3), + new(2022, 9, 14), + new(2022, 5, 5), + new(2022, 7, 13), + new(2021, 7, 18), + new(2021, 7, 23), + ]); + + var fbi = new Pub("Farr Bay Inn", new[] { "Guinness", "Heineken", "Carlsberg", "Bathams", "Tennents" }); + ((List)fbi.DaysVisited).AddRange( + [ + new(2022, 11, 30), + new(2022, 2, 15), + new(2021, 12, 9), + new(2022, 8, 5), + new(2021, 11, 19), + new(2022, 12, 20), + new(2021, 6, 5), + new(2021, 2, 27), + new(2021, 6, 17), + new(2023, 3, 1), + new(2021, 2, 23), + new(2021, 9, 6), + new(2023, 2, 22), + new(2022, 1, 25), + ]); + + var eltisley = new Pub( + "The Eltisley", + new[] { "Oakham", "Carling", "Guinness", "Heineken", "John Smiths", "Stella Artois", "Carlsberg", "Bathams", "Tennents" }); + ((List)eltisley.DaysVisited).AddRange( + [ + new(2022, 6, 19), + new(2021, 1, 15), + new(2022, 3, 24), + new(2023, 2, 26), + new(2021, 1, 11), + new(2022, 3, 19), + ]); + + await AddRangeAsync( + new DogWalk("Ailsworth to Nene") + { + ClosestPub = feathers, + Terrain = Terrain.River, + DaysVisited = new ReadOnlyCollection( + [ + new(2022, 11, 17), + new(2021, 9, 25), + new(2022, 12, 21), + new(2022, 11, 7), + new(2022, 8, 9), + new(2021, 7, 21), + new(2022, 1, 15), + new(2022, 9, 29), + ]) + }, + new DogWalk("Caster Hanglands") + { + ClosestPub = feathers, + Terrain = Terrain.Forest, + DaysVisited = new ReadOnlyCollection( + [ + new(2022, 3, 10), + new(2021, 6, 5), + new(2021, 12, 1), + new(2022, 3, 8), + new(2022, 6, 10), + new(2022, 11, 13), + new(2022, 2, 28), + new(2021, 5, 10), + new(2021, 6, 25), + ]) + }, + new DogWalk("Ferry Meadows") + { + ClosestPub = oak, + Terrain = Terrain.Park, + DaysVisited = new ReadOnlyCollection( + [ + new(2021, 1, 2), + new(2021, 8, 7), + new(2023, 3, 22), + new(2021, 4, 25), + new(2022, 6, 9), + new(2022, 4, 22), + new(2022, 7, 21), + new(2022, 6, 21), + ]) + }, + new DogWalk("Woodnewton") + { + ClosestPub = swan, + Terrain = Terrain.Village, + DaysVisited = new ReadOnlyCollection( + [ + new(2021, 2, 24), + new(2023, 4, 4), + new(2021, 2, 19), + new(2022, 8, 3), + new(2022, 9, 14), + new(2022, 5, 5), + new(2022, 7, 13), + new(2021, 7, 18), + new(2021, 7, 23), + ]) + }, + new DogWalk("Eltisley") + { + ClosestPub = eltisley, + Terrain = Terrain.Village, + DaysVisited = new ReadOnlyCollection( + [ + new(2022, 6, 19), + new(2021, 1, 15), + new(2021, 9, 29), + new(2022, 3, 24), + new(2023, 3, 2), + new(2023, 2, 26), + new(2021, 1, 11), + new(2022, 3, 19), + ]) + }, + new DogWalk("Farr Beach") + { + ClosestPub = fbi, + Terrain = Terrain.Beach, + DaysVisited = new ReadOnlyCollection( + [ + new(2022, 11, 30), + new(2021, 10, 28), + new(2022, 2, 15), + new(2021, 12, 9), + new(2022, 5, 22), + new(2022, 8, 5), + new(2021, 11, 19), + new(2022, 7, 29), + new(2022, 12, 20), + new(2021, 6, 5), + new(2021, 6, 25), + ]) + }, + new DogWalk("Newlands") + { + ClosestPub = fbi, + Terrain = Terrain.Hills, + DaysVisited = new ReadOnlyCollection( + [ + new(2021, 2, 27), + new(2021, 6, 17), + new(2021, 8, 6), + new(2023, 3, 1), + new(2021, 2, 23), + new(2022, 3, 17), + new(2021, 9, 6), + new(2023, 2, 22), + new(2022, 1, 25), + ]) + }); + + await SaveChangesAsync(); + } + } +} diff --git a/samples/core/Miscellaneous/NewInEFCore9/Program.cs b/samples/core/Miscellaneous/NewInEFCore9/Program.cs index 8fa1f3c3da..9f63b9e133 100644 --- a/samples/core/Miscellaneous/NewInEFCore9/Program.cs +++ b/samples/core/Miscellaneous/NewInEFCore9/Program.cs @@ -4,24 +4,29 @@ public class Program { public static async Task Main() { - await QuerySample.Query_improvements_in_EF9(); - await QuerySample.Query_improvements_in_EF9_on_SQLite(); - - // Note that SQL Server 2022 is required for Greater and Least queries. - // await LeastGreatestSample.Queries_using_Least_and_Greatest(); - await LeastGreatestSample.Queries_using_Least_and_Greatest_on_SQLite(); - - await CustomConventionsSample.Conventions_enhancements_in_EF9(); - - await JsonColumnsSample.Columns_from_JSON_are_pruned_when_needed(); - await JsonColumnsSample.Columns_from_JSON_are_pruned_when_needed_on_SQLite(); - - await ExecuteUpdateSample.ExecuteUpdate_for_complex_type_instances(); - await ExecuteUpdateSample.ExecuteUpdate_for_complex_type_instances_on_SQLite(); - - await HierarchyIdSample.SQL_Server_HierarchyId(); - - await ModelBuildingSample.Model_building_improvements_in_EF9(); - + await PrimitiveCollectionsSample.Queries_using_readonly_primitive_collections(); + await PrimitiveCollectionsSample.Queries_using_readonly_primitive_collections_SQLite(); + + // await ComplexTypesSample.GropupBy_complex_type_instances(); + // await ComplexTypesSample.GropupBy_complex_type_instances_on_SQLite(); + // + // await QuerySample.Query_improvements_in_EF9(); + // await QuerySample.Query_improvements_in_EF9_on_SQLite(); + // + // // Note that SQL Server 2022 is required for Greater and Least queries. + // // await LeastGreatestSample.Queries_using_Least_and_Greatest(); + // await LeastGreatestSample.Queries_using_Least_and_Greatest_on_SQLite(); + // + // await CustomConventionsSample.Conventions_enhancements_in_EF9(); + // + // await JsonColumnsSample.Columns_from_JSON_are_pruned_when_needed(); + // await JsonColumnsSample.Columns_from_JSON_are_pruned_when_needed_on_SQLite(); + // + // await ExecuteUpdateSample.ExecuteUpdate_for_complex_type_instances(); + // await ExecuteUpdateSample.ExecuteUpdate_for_complex_type_instances_on_SQLite(); + // + // await HierarchyIdSample.SQL_Server_HierarchyId(); + // + // await ModelBuildingSample.Model_building_improvements_in_EF9(); } } diff --git a/samples/core/Miscellaneous/NullableReferenceTypes/NullableReferenceTypesContext.cs b/samples/core/Miscellaneous/NullableReferenceTypes/NullableReferenceTypesContext.cs index b65950a184..d38a0e7461 100644 --- a/samples/core/Miscellaneous/NullableReferenceTypes/NullableReferenceTypesContext.cs +++ b/samples/core/Miscellaneous/NullableReferenceTypes/NullableReferenceTypesContext.cs @@ -11,7 +11,7 @@ public class NullableReferenceTypesContext : DbContext protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => optionsBuilder .UseSqlServer( - @"Server=(localdb)\mssqllocaldb;Database=EFNullableReferenceTypes;Trusted_Connection=True"); + @"Server=(localdb)\mssqllocaldb;Database=EFNullableReferenceTypes;Trusted_Connection=True;ConnectRetryCount=0"); } #endregion } diff --git a/samples/core/Modeling/BulkConfiguration/BlogsContext.cs b/samples/core/Modeling/BulkConfiguration/BlogsContext.cs index f64cf6f82c..85a831cf7c 100644 --- a/samples/core/Modeling/BulkConfiguration/BlogsContext.cs +++ b/samples/core/Modeling/BulkConfiguration/BlogsContext.cs @@ -183,7 +183,7 @@ public abstract class BlogsContext : DbContext protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => (optionsBuilder.UseSqlServer( - @$"Server=(localdb)\mssqllocaldb;Database=EFModeling.BulkConfiguration.{GetType().Name}")) + @$"Server=(localdb)\mssqllocaldb;Database=EFModeling.BulkConfiguration.{GetType().Name};ConnectRetryCount=0")) .EnableSensitiveDataLogging() .LogTo( s => diff --git a/samples/core/Modeling/BulkConfiguration/CurrencyContext.cs b/samples/core/Modeling/BulkConfiguration/CurrencyContext.cs index c8ed0ed99a..97fe4f3dcb 100644 --- a/samples/core/Modeling/BulkConfiguration/CurrencyContext.cs +++ b/samples/core/Modeling/BulkConfiguration/CurrencyContext.cs @@ -19,7 +19,7 @@ protected override void ConfigureConventions(ModelConfigurationBuilder configura protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => optionsBuilder.UseSqlServer( - @"Server=(localdb)\mssqllocaldb;Database=EFModeling.BulkConfiguration.Currency;Trusted_Connection=True") + @"Server=(localdb)\mssqllocaldb;Database=EFModeling.BulkConfiguration.Currency;Trusted_Connection=True;ConnectRetryCount=0") .LogTo(Console.WriteLine, minimumLevel: Microsoft.Extensions.Logging.LogLevel.Information) .EnableSensitiveDataLogging(); -} \ No newline at end of file +} diff --git a/samples/core/Modeling/BulkConfiguration/MetadataAPIContext.cs b/samples/core/Modeling/BulkConfiguration/MetadataAPIContext.cs index ff09e48e2d..c8f2b87fe2 100644 --- a/samples/core/Modeling/BulkConfiguration/MetadataAPIContext.cs +++ b/samples/core/Modeling/BulkConfiguration/MetadataAPIContext.cs @@ -26,7 +26,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => optionsBuilder.UseSqlServer( - @"Server=(localdb)\mssqllocaldb;Database=EFModeling.BulkConfiguration;Trusted_Connection=True") + @"Server=(localdb)\mssqllocaldb;Database=EFModeling.BulkConfiguration;Trusted_Connection=True;ConnectRetryCount=0") .LogTo(Console.WriteLine, minimumLevel: Microsoft.Extensions.Logging.LogLevel.Information) .EnableSensitiveDataLogging(); -} \ No newline at end of file +} diff --git a/samples/core/Modeling/BulkConfiguration/ModelBuildingConventionsSample.cs b/samples/core/Modeling/BulkConfiguration/ModelBuildingConventionsSample.cs index f6ab99d7c0..de9d809485 100644 --- a/samples/core/Modeling/BulkConfiguration/ModelBuildingConventionsSample.cs +++ b/samples/core/Modeling/BulkConfiguration/ModelBuildingConventionsSample.cs @@ -273,7 +273,7 @@ public class LaundryContext : DbContext public DbSet LaundryBaskets => Set(); protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) - => optionsBuilder.UseSqlServer(@$"Server=(localdb)\mssqllocaldb;Database={GetType().Name}"); + => optionsBuilder.UseSqlServer(@$"Server=(localdb)\mssqllocaldb;Database={GetType().Name};ConnectRetryCount=0"); #region ReplaceConvention protected override void ConfigureConventions(ModelConfigurationBuilder configurationBuilder) diff --git a/samples/core/Modeling/BulkConfiguration/PreConventionContext.cs b/samples/core/Modeling/BulkConfiguration/PreConventionContext.cs index 96f45459e3..79e6c944da 100644 --- a/samples/core/Modeling/BulkConfiguration/PreConventionContext.cs +++ b/samples/core/Modeling/BulkConfiguration/PreConventionContext.cs @@ -37,7 +37,7 @@ protected override void ConfigureConventions(ModelConfigurationBuilder configura protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => optionsBuilder.UseSqlServer( - @"Server=(localdb)\mssqllocaldb;Database=EFModeling.BulkConfiguration;Trusted_Connection=True") + @"Server=(localdb)\mssqllocaldb;Database=EFModeling.BulkConfiguration;Trusted_Connection=True;ConnectRetryCount=0") .LogTo(Console.WriteLine, minimumLevel: Microsoft.Extensions.Logging.LogLevel.Information) .EnableSensitiveDataLogging(); -} \ No newline at end of file +} diff --git a/samples/core/Modeling/DataSeeding/DataSeedingContext.cs b/samples/core/Modeling/DataSeeding/DataSeedingContext.cs index a8d9104f14..33624e27e0 100644 --- a/samples/core/Modeling/DataSeeding/DataSeedingContext.cs +++ b/samples/core/Modeling/DataSeeding/DataSeedingContext.cs @@ -9,7 +9,7 @@ public class DataSeedingContext : DbContext protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => optionsBuilder - .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=EFDataSeeding;Trusted_Connection=True"); + .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=EFDataSeeding;Trusted_Connection=True;ConnectRetryCount=0"); protected override void OnModelCreating(ModelBuilder modelBuilder) { @@ -43,4 +43,4 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) new { PostId = 2, First = "Diego", Last = "Vega" }); #endregion } -} \ No newline at end of file +} diff --git a/samples/core/Modeling/EntityTypes/EntityTypes.cs b/samples/core/Modeling/EntityTypes/EntityTypes.cs index 32d676e9b0..88b8beb154 100644 --- a/samples/core/Modeling/EntityTypes/EntityTypes.cs +++ b/samples/core/Modeling/EntityTypes/EntityTypes.cs @@ -62,6 +62,6 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder.UseSqlServer( - @"Server=(localdb)\mssqllocaldb;Database=EFModeling.EntityTypeToFunctionMapping;Trusted_Connection=True"); + @"Server=(localdb)\mssqllocaldb;Database=EFModeling.EntityTypeToFunctionMapping;Trusted_Connection=True;ConnectRetryCount=0"); } -} \ No newline at end of file +} diff --git a/samples/core/Modeling/KeylessEntityTypes/Program.cs b/samples/core/Modeling/KeylessEntityTypes/Program.cs index 8563d0eea2..6a13a2937b 100644 --- a/samples/core/Modeling/KeylessEntityTypes/Program.cs +++ b/samples/core/Modeling/KeylessEntityTypes/Program.cs @@ -101,7 +101,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder .UseSqlServer( - @"Server=(localdb)\mssqllocaldb;Database=Sample.KeylessEntityTypes;Trusted_Connection=True") + @"Server=(localdb)\mssqllocaldb;Database=Sample.KeylessEntityTypes;Trusted_Connection=True;ConnectRetryCount=0") .UseLoggerFactory(_loggerFactory); } diff --git a/samples/core/Modeling/OwnedEntities/OwnedEntityContext.cs b/samples/core/Modeling/OwnedEntities/OwnedEntityContext.cs index de75d9472f..1654f8bee4 100644 --- a/samples/core/Modeling/OwnedEntities/OwnedEntityContext.cs +++ b/samples/core/Modeling/OwnedEntities/OwnedEntityContext.cs @@ -9,7 +9,7 @@ public class OwnedEntityContext : DbContext protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => optionsBuilder - .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=EFOwnedEntity;Trusted_Connection=True"); + .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=EFOwnedEntity;Trusted_Connection=True;ConnectRetryCount=0"); protected override void OnModelCreating(ModelBuilder modelBuilder) { @@ -73,4 +73,4 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) }); #endregion } -} \ No newline at end of file +} diff --git a/samples/core/Modeling/TableSplitting/TableSplittingContext.cs b/samples/core/Modeling/TableSplitting/TableSplittingContext.cs index ec891e91fc..23b2810454 100644 --- a/samples/core/Modeling/TableSplitting/TableSplittingContext.cs +++ b/samples/core/Modeling/TableSplitting/TableSplittingContext.cs @@ -9,7 +9,7 @@ public class TableSplittingContext : DbContext protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => optionsBuilder - .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=EFTableSplitting;Trusted_Connection=True"); + .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=EFTableSplitting;Trusted_Connection=True;ConnectRetryCount=0"); protected override void OnModelCreating(ModelBuilder modelBuilder) { diff --git a/samples/core/Modeling/ValueConversions/CaseInsensitiveStrings.cs b/samples/core/Modeling/ValueConversions/CaseInsensitiveStrings.cs index 96a463d786..cd97d29933 100644 --- a/samples/core/Modeling/ValueConversions/CaseInsensitiveStrings.cs +++ b/samples/core/Modeling/ValueConversions/CaseInsensitiveStrings.cs @@ -81,7 +81,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => optionsBuilder .LogTo(Console.WriteLine, new[] { RelationalEventId.CommandExecuted }) - .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=CaseInsensitiveStrings;Trusted_Connection=True") + .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=CaseInsensitiveStrings;Trusted_Connection=True;ConnectRetryCount=0") .EnableSensitiveDataLogging(); } diff --git a/samples/core/Modeling/ValueConversions/EncryptPropertyValues.cs b/samples/core/Modeling/ValueConversions/EncryptPropertyValues.cs index d4874e422a..45eedc1266 100644 --- a/samples/core/Modeling/ValueConversions/EncryptPropertyValues.cs +++ b/samples/core/Modeling/ValueConversions/EncryptPropertyValues.cs @@ -50,7 +50,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => optionsBuilder .LogTo(Console.WriteLine, new[] { RelationalEventId.CommandExecuted }) - .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=EncryptPropertyValues;Trusted_Connection=True") + .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=EncryptPropertyValues;Trusted_Connection=True;ConnectRetryCount=0") .EnableSensitiveDataLogging(); } @@ -62,4 +62,4 @@ public class User public string Password { get; set; } } #endregion -} \ No newline at end of file +} diff --git a/samples/core/Modeling/ValueConversions/EnumToStringConversions.cs b/samples/core/Modeling/ValueConversions/EnumToStringConversions.cs index 791868a445..efc314f06b 100644 --- a/samples/core/Modeling/ValueConversions/EnumToStringConversions.cs +++ b/samples/core/Modeling/ValueConversions/EnumToStringConversions.cs @@ -296,7 +296,7 @@ public class SampleDbContextBase : DbContext protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => optionsBuilder .LogTo(Console.WriteLine, new[] { RelationalEventId.CommandExecuted }) - .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=EnumConversions;Trusted_Connection=True") + .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=EnumConversions;Trusted_Connection=True;ConnectRetryCount=0") .EnableSensitiveDataLogging(); } @@ -331,4 +331,4 @@ public class User public int Id { get; set; } public bool IsActive { get; set; } } -} \ No newline at end of file +} diff --git a/samples/core/Modeling/ValueConversions/FixedLengthStrings.cs b/samples/core/Modeling/ValueConversions/FixedLengthStrings.cs index 19977acfa2..9ec9db2493 100644 --- a/samples/core/Modeling/ValueConversions/FixedLengthStrings.cs +++ b/samples/core/Modeling/ValueConversions/FixedLengthStrings.cs @@ -64,7 +64,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) var converter = new ValueConverter( v => v, v => v.Trim()); - + var comparer = new ValueComparer( (l, r) => string.Equals(l, r, StringComparison.OrdinalIgnoreCase), v => v.ToUpper().GetHashCode(), @@ -87,7 +87,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => optionsBuilder .LogTo(Console.WriteLine, new[] { RelationalEventId.CommandExecuted }) - .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=FixedLengthStrings;Trusted_Connection=True") + .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=FixedLengthStrings;Trusted_Connection=True;ConnectRetryCount=0") .EnableSensitiveDataLogging(); } @@ -110,4 +110,4 @@ public class Post public Blog Blog { get; set; } } #endregion -} \ No newline at end of file +} diff --git a/samples/core/Modeling/ValueConversions/PreserveDateTimeKind.cs b/samples/core/Modeling/ValueConversions/PreserveDateTimeKind.cs index 1902a789f6..9edc93aab4 100644 --- a/samples/core/Modeling/ValueConversions/PreserveDateTimeKind.cs +++ b/samples/core/Modeling/ValueConversions/PreserveDateTimeKind.cs @@ -84,7 +84,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => optionsBuilder .LogTo(Console.WriteLine, new[] { RelationalEventId.CommandExecuted }) - .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=PreserveDateTimeKind;Trusted_Connection=True") + .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=PreserveDateTimeKind;Trusted_Connection=True;ConnectRetryCount=0") .EnableSensitiveDataLogging(); } @@ -101,4 +101,4 @@ public class Post public DateTime DeletedOn { get; set; } } #endregion -} \ No newline at end of file +} diff --git a/samples/core/Modeling/ValueConversions/ULongConcurrency.cs b/samples/core/Modeling/ValueConversions/ULongConcurrency.cs index 83feb2e84e..2eb5717d60 100644 --- a/samples/core/Modeling/ValueConversions/ULongConcurrency.cs +++ b/samples/core/Modeling/ValueConversions/ULongConcurrency.cs @@ -80,7 +80,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => optionsBuilder .LogTo(Console.WriteLine, new[] { RelationalEventId.CommandExecuted }) - .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=ULongConcurrency;Trusted_Connection=True") + .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=ULongConcurrency;Trusted_Connection=True;ConnectRetryCount=0") .EnableSensitiveDataLogging(); } @@ -92,4 +92,4 @@ public class Blog public ulong Version { get; set; } } #endregion -} \ No newline at end of file +} diff --git a/samples/core/Modeling/ValueConversions/WithMappingHints.cs b/samples/core/Modeling/ValueConversions/WithMappingHints.cs index f10245e97e..9610227ab7 100644 --- a/samples/core/Modeling/ValueConversions/WithMappingHints.cs +++ b/samples/core/Modeling/ValueConversions/WithMappingHints.cs @@ -63,7 +63,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => optionsBuilder .LogTo(Console.WriteLine, new[] { RelationalEventId.CommandExecuted }) - .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=WithMappingHints;Trusted_Connection=True") + .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=WithMappingHints;Trusted_Connection=True;ConnectRetryCount=0") .EnableSensitiveDataLogging(); } @@ -86,4 +86,4 @@ public readonly struct Dollars public Dollars(decimal amount) => Amount = amount; public decimal Amount { get; } } -} \ No newline at end of file +} diff --git a/samples/core/Performance/Other/BloggingContext.cs b/samples/core/Performance/Other/BloggingContext.cs index 4543205969..c2318d6276 100644 --- a/samples/core/Performance/Other/BloggingContext.cs +++ b/samples/core/Performance/Other/BloggingContext.cs @@ -14,7 +14,7 @@ public class BloggingContext : DbContext protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder - .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=Blogging;Trusted_Connection=True") + .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=Blogging;Trusted_Connection=True;ConnectRetryCount=0") .LogTo(Console.WriteLine, LogLevel.Information); } #endregion diff --git a/samples/core/Performance/Other/EmployeeContext.cs b/samples/core/Performance/Other/EmployeeContext.cs index 15213f6590..caa2e481eb 100644 --- a/samples/core/Performance/Other/EmployeeContext.cs +++ b/samples/core/Performance/Other/EmployeeContext.cs @@ -11,7 +11,7 @@ public class EmployeeContext : DbContext protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder - .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=Blogging;Trusted_Connection=True") + .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=Blogging;Trusted_Connection=True;ConnectRetryCount=0") .LogTo(Console.WriteLine, LogLevel.Information); } } @@ -21,4 +21,4 @@ public class Employee public int Id { get; set; } public string Name { get; set; } public int Salary { get; set; } -} \ No newline at end of file +} diff --git a/samples/core/Performance/Other/ExtensionsLoggingContext.cs b/samples/core/Performance/Other/ExtensionsLoggingContext.cs index 82348470b0..60f6e2602f 100644 --- a/samples/core/Performance/Other/ExtensionsLoggingContext.cs +++ b/samples/core/Performance/Other/ExtensionsLoggingContext.cs @@ -12,8 +12,8 @@ private static ILoggerFactory ContextLoggerFactory protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder - .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=Blogging;Trusted_Connection=True") + .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=Blogging;Trusted_Connection=True;ConnectRetryCount=0") .UseLoggerFactory(ContextLoggerFactory); } #endregion -} \ No newline at end of file +} diff --git a/samples/core/Performance/Other/LazyLoading/LazyBloggingContext.cs b/samples/core/Performance/Other/LazyLoading/LazyBloggingContext.cs index 2feb273536..3514e0cc9b 100644 --- a/samples/core/Performance/Other/LazyLoading/LazyBloggingContext.cs +++ b/samples/core/Performance/Other/LazyLoading/LazyBloggingContext.cs @@ -12,7 +12,7 @@ public class LazyBloggingContext : DbContext protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => optionsBuilder - .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=Blogging;Trusted_Connection=True") + .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=Blogging;Trusted_Connection=True;ConnectRetryCount=0") .LogTo(Console.WriteLine, LogLevel.Information) .UseLazyLoadingProxies(); } @@ -33,4 +33,4 @@ public class Post public int BlogId { get; set; } public virtual Blog Blog { get; set; } -} \ No newline at end of file +} diff --git a/samples/core/Performance/Other/Program.cs b/samples/core/Performance/Other/Program.cs index f5097b6be7..f53ed94b44 100644 --- a/samples/core/Performance/Other/Program.cs +++ b/samples/core/Performance/Other/Program.cs @@ -214,7 +214,7 @@ private static async Task Main(string[] args) using (var context = new PooledBloggingContext( new DbContextOptionsBuilder() - .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=Blogging;Trusted_Connection=True") + .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=Blogging;Trusted_Connection=True;ConnectRetryCount=0") .Options)) { context.Database.EnsureDeleted(); @@ -223,7 +223,7 @@ private static async Task Main(string[] args) #region DbContextPoolingWithoutDI var options = new DbContextOptionsBuilder() - .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=Blogging;Trusted_Connection=True") + .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=Blogging;Trusted_Connection=True;ConnectRetryCount=0") .Options; var factory = new PooledDbContextFactory(options); @@ -244,4 +244,4 @@ private static async Task Main(string[] args) #endregion } } -} \ No newline at end of file +} diff --git a/samples/core/Querying/ClientEvaluation/BloggingContext.cs b/samples/core/Querying/ClientEvaluation/BloggingContext.cs index e8bbaf6f75..a30e355c17 100644 --- a/samples/core/Querying/ClientEvaluation/BloggingContext.cs +++ b/samples/core/Querying/ClientEvaluation/BloggingContext.cs @@ -17,6 +17,6 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder.UseSqlServer( - @"Server=(localdb)\mssqllocaldb;Database=EFQuerying.ClientEvaluation;Trusted_Connection=True"); + @"Server=(localdb)\mssqllocaldb;Database=EFQuerying.ClientEvaluation;Trusted_Connection=True;ConnectRetryCount=0"); } -} \ No newline at end of file +} diff --git a/samples/core/Querying/ComplexQuery/BloggingContext.cs b/samples/core/Querying/ComplexQuery/BloggingContext.cs index 397e861967..9637383ef3 100644 --- a/samples/core/Querying/ComplexQuery/BloggingContext.cs +++ b/samples/core/Querying/ComplexQuery/BloggingContext.cs @@ -103,6 +103,6 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder.UseSqlServer( - @"Server=(localdb)\mssqllocaldb;Database=EFQuerying.ComplexQuery;Trusted_Connection=True"); + @"Server=(localdb)\mssqllocaldb;Database=EFQuerying.ComplexQuery;Trusted_Connection=True;ConnectRetryCount=0"); } -} \ No newline at end of file +} diff --git a/samples/core/Querying/NullSemantics/NullSemanticsContext.cs b/samples/core/Querying/NullSemantics/NullSemanticsContext.cs index e2fc5ad25c..76c04fc54e 100644 --- a/samples/core/Querying/NullSemantics/NullSemanticsContext.cs +++ b/samples/core/Querying/NullSemantics/NullSemanticsContext.cs @@ -18,7 +18,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) } optionsBuilder.UseSqlServer( - @"Server=(localdb)\mssqllocaldb;Database=NullSemanticsSample;Trusted_Connection=True;MultipleActiveResultSets=true"); + @"Server=(localdb)\mssqllocaldb;Database=NullSemanticsSample;Trusted_Connection=True;MultipleActiveResultSets=true;ConnectRetryCount=0"); } protected override void OnModelCreating(ModelBuilder modelBuilder) @@ -65,4 +65,4 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) String2 = null }); } -} \ No newline at end of file +} diff --git a/samples/core/Querying/Overview/BloggingContext.cs b/samples/core/Querying/Overview/BloggingContext.cs index 28e257912c..849e8b9e3f 100644 --- a/samples/core/Querying/Overview/BloggingContext.cs +++ b/samples/core/Querying/Overview/BloggingContext.cs @@ -17,6 +17,6 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder.UseSqlServer( - @"Server=(localdb)\mssqllocaldb;Database=EFQuerying.Overview;Trusted_Connection=True"); + @"Server=(localdb)\mssqllocaldb;Database=EFQuerying.Overview;Trusted_Connection=True;ConnectRetryCount=0"); } -} \ No newline at end of file +} diff --git a/samples/core/Querying/Pagination/BloggingContext.cs b/samples/core/Querying/Pagination/BloggingContext.cs index cf7a2c86d0..b154ede4e8 100644 --- a/samples/core/Querying/Pagination/BloggingContext.cs +++ b/samples/core/Querying/Pagination/BloggingContext.cs @@ -14,7 +14,7 @@ public class BloggingContext : DbContext protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder - .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=Blogging;Trusted_Connection=True") + .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=Blogging;Trusted_Connection=True;ConnectRetryCount=0") .LogTo(Console.WriteLine, LogLevel.Information); } #endregion @@ -42,4 +42,4 @@ public class Post public int BlogId { get; set; } public Blog Blog { get; set; } -} \ No newline at end of file +} diff --git a/samples/core/Querying/QueryFilters/AnimalContext.cs b/samples/core/Querying/QueryFilters/AnimalContext.cs index f5b6f0fb07..7612ba09fc 100644 --- a/samples/core/Querying/QueryFilters/AnimalContext.cs +++ b/samples/core/Querying/QueryFilters/AnimalContext.cs @@ -12,7 +12,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder .UseSqlServer( - @"Server=(localdb)\mssqllocaldb;Database=Querying.QueryFilters.Animals;Trusted_Connection=True"); + @"Server=(localdb)\mssqllocaldb;Database=Querying.QueryFilters.Animals;Trusted_Connection=True;ConnectRetryCount=0"); } protected override void OnModelCreating(ModelBuilder modelBuilder) @@ -27,4 +27,4 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) // Invalid query filter configuration as it causes cycles in query filters //modelBuilder.Entity().HasQueryFilter(a => a.Owner.Name != "John"); } -} \ No newline at end of file +} diff --git a/samples/core/Querying/QueryFilters/BloggingContext.cs b/samples/core/Querying/QueryFilters/BloggingContext.cs index ca54251483..60d8ed7121 100644 --- a/samples/core/Querying/QueryFilters/BloggingContext.cs +++ b/samples/core/Querying/QueryFilters/BloggingContext.cs @@ -19,7 +19,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder .UseSqlServer( - @"Server=(localdb)\mssqllocaldb;Database=Querying.QueryFilters.Blogging;Trusted_Connection=True"); + @"Server=(localdb)\mssqllocaldb;Database=Querying.QueryFilters.Blogging;Trusted_Connection=True;ConnectRetryCount=0"); } protected override void OnModelCreating(ModelBuilder modelBuilder) @@ -52,4 +52,4 @@ public override int SaveChanges() return base.SaveChanges(); } -} \ No newline at end of file +} diff --git a/samples/core/Querying/QueryFilters/FilteredBloggingContextRequired.cs b/samples/core/Querying/QueryFilters/FilteredBloggingContextRequired.cs index 2cac7cc0fe..d9a4ad1a64 100644 --- a/samples/core/Querying/QueryFilters/FilteredBloggingContextRequired.cs +++ b/samples/core/Querying/QueryFilters/FilteredBloggingContextRequired.cs @@ -11,7 +11,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder .UseSqlServer( - @"Server=(localdb)\mssqllocaldb;Database=Querying.QueryFilters.BloggingRequired;Trusted_Connection=True"); + @"Server=(localdb)\mssqllocaldb;Database=Querying.QueryFilters.BloggingRequired;Trusted_Connection=True;ConnectRetryCount=0"); } protected override void OnModelCreating(ModelBuilder modelBuilder) @@ -53,4 +53,4 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) #endregion } } -} \ No newline at end of file +} diff --git a/samples/core/Querying/RelatedData/BloggingContext.cs b/samples/core/Querying/RelatedData/BloggingContext.cs index 9eb800f7e0..5644a1a007 100644 --- a/samples/core/Querying/RelatedData/BloggingContext.cs +++ b/samples/core/Querying/RelatedData/BloggingContext.cs @@ -122,6 +122,6 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder.UseSqlServer( - @"Server=(localdb)\mssqllocaldb;Database=EFQuerying.ComplexQuery;Trusted_Connection=True"); + @"Server=(localdb)\mssqllocaldb;Database=EFQuerying.ComplexQuery;Trusted_Connection=True;ConnectRetryCount=0"); } -} \ No newline at end of file +} diff --git a/samples/core/Querying/RelatedData/SplitQueriesBloggingContext.cs b/samples/core/Querying/RelatedData/SplitQueriesBloggingContext.cs index b1c55acafe..769d83edf4 100644 --- a/samples/core/Querying/RelatedData/SplitQueriesBloggingContext.cs +++ b/samples/core/Querying/RelatedData/SplitQueriesBloggingContext.cs @@ -9,8 +9,8 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder .UseSqlServer( - @"Server=(localdb)\mssqllocaldb;Database=EFQuerying;Trusted_Connection=True", + @"Server=(localdb)\mssqllocaldb;Database=EFQuerying;Trusted_Connection=True;ConnectRetryCount=0", o => o.UseQuerySplittingBehavior(QuerySplittingBehavior.SplitQuery)); } #endregion -} \ No newline at end of file +} diff --git a/samples/core/Querying/SqlQueries/BloggingContext.cs b/samples/core/Querying/SqlQueries/BloggingContext.cs index fc3ed832cb..0251c3525d 100644 --- a/samples/core/Querying/SqlQueries/BloggingContext.cs +++ b/samples/core/Querying/SqlQueries/BloggingContext.cs @@ -52,6 +52,6 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder.UseSqlServer( - @"Server=(localdb)\mssqllocaldb;Database=EFQuerying.RawSQL;Trusted_Connection=True"); + @"Server=(localdb)\mssqllocaldb;Database=EFQuerying.RawSQL;Trusted_Connection=True;ConnectRetryCount=0"); } -} \ No newline at end of file +} diff --git a/samples/core/Querying/Tags/SpatialContext.cs b/samples/core/Querying/Tags/SpatialContext.cs index 65f4085f94..89b4128915 100644 --- a/samples/core/Querying/Tags/SpatialContext.cs +++ b/samples/core/Querying/Tags/SpatialContext.cs @@ -24,7 +24,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder.UseSqlServer( - @"Server=(localdb)\mssqllocaldb;Database=EFQuerying.Tags;Trusted_Connection=True", + @"Server=(localdb)\mssqllocaldb;Database=EFQuerying.Tags;Trusted_Connection=True;ConnectRetryCount=0", b => b.UseNetTopologySuite()); } -} \ No newline at end of file +} diff --git a/samples/core/Querying/Tracking/BloggingContext.cs b/samples/core/Querying/Tracking/BloggingContext.cs index 7355fc9e65..a3234e42b7 100644 --- a/samples/core/Querying/Tracking/BloggingContext.cs +++ b/samples/core/Querying/Tracking/BloggingContext.cs @@ -17,6 +17,6 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder - .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=EFQuerying.Tracking;Trusted_Connection=True"); + .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=EFQuerying.Tracking;Trusted_Connection=True;ConnectRetryCount=0"); } -} \ No newline at end of file +} diff --git a/samples/core/Querying/Tracking/NonTrackingBloggingContext.cs b/samples/core/Querying/Tracking/NonTrackingBloggingContext.cs index 27cb4b9e36..2690db12e5 100644 --- a/samples/core/Querying/Tracking/NonTrackingBloggingContext.cs +++ b/samples/core/Querying/Tracking/NonTrackingBloggingContext.cs @@ -18,8 +18,8 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder - .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=EFQuerying.Tracking;Trusted_Connection=True") + .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=EFQuerying.Tracking;Trusted_Connection=True;ConnectRetryCount=0") .UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking); } #endregion -} \ No newline at end of file +} diff --git a/samples/core/Querying/UserDefinedFunctionMapping/Model.cs b/samples/core/Querying/UserDefinedFunctionMapping/Model.cs index 245c7d782d..188df7d56a 100644 --- a/samples/core/Querying/UserDefinedFunctionMapping/Model.cs +++ b/samples/core/Querying/UserDefinedFunctionMapping/Model.cs @@ -214,6 +214,6 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder.UseSqlServer( - @"Server=(localdb)\mssqllocaldb;Database=EFQuerying.UserDefinedFunctionMapping;Trusted_Connection=True"); + @"Server=(localdb)\mssqllocaldb;Database=EFQuerying.UserDefinedFunctionMapping;Trusted_Connection=True;ConnectRetryCount=0"); } -} \ No newline at end of file +} diff --git a/samples/core/Samples.sln b/samples/core/Samples.sln index 13b6ced270..3bbd6d00f9 100644 --- a/samples/core/Samples.sln +++ b/samples/core/Samples.sln @@ -203,6 +203,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "App", "Miscellaneous\NewInE EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Model", "Miscellaneous\NewInEFCore9.CompiledModels\Model\Model.csproj", "{8E9DD759-B6D0-4424-BC6C-97ECE559CE02}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NewInEFCore9.Cosmos", "Miscellaneous\NewInEFCore9.Cosmos\NewInEFCore9.Cosmos.csproj", "{C636065F-C124-4051-90DA-3EA2A0817471}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -561,6 +563,10 @@ Global {8E9DD759-B6D0-4424-BC6C-97ECE559CE02}.Debug|Any CPU.Build.0 = Debug|Any CPU {8E9DD759-B6D0-4424-BC6C-97ECE559CE02}.Release|Any CPU.ActiveCfg = Release|Any CPU {8E9DD759-B6D0-4424-BC6C-97ECE559CE02}.Release|Any CPU.Build.0 = Release|Any CPU + {C636065F-C124-4051-90DA-3EA2A0817471}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C636065F-C124-4051-90DA-3EA2A0817471}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C636065F-C124-4051-90DA-3EA2A0817471}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C636065F-C124-4051-90DA-3EA2A0817471}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -650,6 +656,7 @@ Global {26184A10-7CF8-4ED2-9F70-E00A55BE063B} = {85AFD7F1-6943-40FE-B8EC-AA9DBB42CCA6} {22548A1B-0833-49E9-A04E-A7E8690EAE03} = {26184A10-7CF8-4ED2-9F70-E00A55BE063B} {8E9DD759-B6D0-4424-BC6C-97ECE559CE02} = {26184A10-7CF8-4ED2-9F70-E00A55BE063B} + {C636065F-C124-4051-90DA-3EA2A0817471} = {85AFD7F1-6943-40FE-B8EC-AA9DBB42CCA6} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {20C98D35-54EF-46A6-8F3B-1855C1AE4F70} diff --git a/samples/core/Saving/Basics/BloggingContext.cs b/samples/core/Saving/Basics/BloggingContext.cs index 535855059c..d2d005449a 100644 --- a/samples/core/Saving/Basics/BloggingContext.cs +++ b/samples/core/Saving/Basics/BloggingContext.cs @@ -10,6 +10,6 @@ public class BloggingContext : DbContext protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder.UseSqlServer( - @"Server=(localdb)\mssqllocaldb;Database=EFSaving.Basics;Trusted_Connection=True"); + @"Server=(localdb)\mssqllocaldb;Database=EFSaving.Basics;Trusted_Connection=True;ConnectRetryCount=0"); } -} \ No newline at end of file +} diff --git a/samples/core/Saving/CascadeDelete/BloggingContext.cs b/samples/core/Saving/CascadeDelete/BloggingContext.cs index 94256d62dc..2c128250e9 100644 --- a/samples/core/Saving/CascadeDelete/BloggingContext.cs +++ b/samples/core/Saving/CascadeDelete/BloggingContext.cs @@ -32,7 +32,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) .ReplaceService() .EnableSensitiveDataLogging() .UseSqlServer( - @"Server=(localdb)\mssqllocaldb;Database=EFSaving.CascadeDelete;Trusted_Connection=True", + @"Server=(localdb)\mssqllocaldb;Database=EFSaving.CascadeDelete;Trusted_Connection=True;ConnectRetryCount=0", b => b.MaxBatchSize(1)); protected override void OnModelCreating(ModelBuilder modelBuilder) @@ -110,4 +110,4 @@ public void Log( public IDisposable BeginScope(TState state) => null; } } -} \ No newline at end of file +} diff --git a/samples/core/Saving/Concurrency/BasicSample.cs b/samples/core/Saving/Concurrency/BasicSample.cs index 12574e3d08..933530b175 100644 --- a/samples/core/Saving/Concurrency/BasicSample.cs +++ b/samples/core/Saving/Concurrency/BasicSample.cs @@ -67,7 +67,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { // Requires NuGet package Microsoft.EntityFrameworkCore.SqlServer optionsBuilder.UseSqlServer( - @"Server=(localdb)\mssqllocaldb;Database=EFSaving.Concurrency;Trusted_Connection=True"); + @"Server=(localdb)\mssqllocaldb;Database=EFSaving.Concurrency;Trusted_Connection=True;ConnectRetryCount=0"); } } diff --git a/samples/core/Saving/Concurrency/ConflictResolutionSample.cs b/samples/core/Saving/Concurrency/ConflictResolutionSample.cs index b78870e2e9..4e6b1c8850 100644 --- a/samples/core/Saving/Concurrency/ConflictResolutionSample.cs +++ b/samples/core/Saving/Concurrency/ConflictResolutionSample.cs @@ -79,7 +79,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { // Requires NuGet package Microsoft.EntityFrameworkCore.SqlServer optionsBuilder.UseSqlServer( - @"Server=(localdb)\mssqllocaldb;Database=EFSaving.Concurrency;Trusted_Connection=True"); + @"Server=(localdb)\mssqllocaldb;Database=EFSaving.Concurrency;Trusted_Connection=True;ConnectRetryCount=0"); } } diff --git a/samples/core/Saving/Disconnected/BloggingContext.cs b/samples/core/Saving/Disconnected/BloggingContext.cs index d61f01d111..41f30b9b59 100644 --- a/samples/core/Saving/Disconnected/BloggingContext.cs +++ b/samples/core/Saving/Disconnected/BloggingContext.cs @@ -10,6 +10,6 @@ public class BloggingContext : DbContext protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder.UseSqlServer( - @"Server=(localdb)\mssqllocaldb;Database=EFSaving.Disconnected;Trusted_Connection=True"); + @"Server=(localdb)\mssqllocaldb;Database=EFSaving.Disconnected;Trusted_Connection=True;ConnectRetryCount=0"); } -} \ No newline at end of file +} diff --git a/samples/core/Saving/RelatedData/Sample.cs b/samples/core/Saving/RelatedData/Sample.cs index 820f74e82d..1ad2df56b1 100644 --- a/samples/core/Saving/RelatedData/Sample.cs +++ b/samples/core/Saving/RelatedData/Sample.cs @@ -75,7 +75,7 @@ public class BloggingContext : DbContext protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder.UseSqlServer( - @"Server=(localdb)\mssqllocaldb;Database=EFSaving.RelatedData;Trusted_Connection=True"); + @"Server=(localdb)\mssqllocaldb;Database=EFSaving.RelatedData;Trusted_Connection=True;ConnectRetryCount=0"); } } @@ -96,4 +96,4 @@ public class Post public int BlogId { get; set; } public Blog Blog { get; set; } } -} \ No newline at end of file +} diff --git a/samples/core/Saving/Transactions/AmbientTransaction.cs b/samples/core/Saving/Transactions/AmbientTransaction.cs index 4ff410c99a..b5ef4100be 100644 --- a/samples/core/Saving/Transactions/AmbientTransaction.cs +++ b/samples/core/Saving/Transactions/AmbientTransaction.cs @@ -10,7 +10,7 @@ public class AmbientTransaction public static void Run() { var connectionString = - @"Server=(localdb)\mssqllocaldb;Database=EFSaving.Transactions;Trusted_Connection=True"; + @"Server=(localdb)\mssqllocaldb;Database=EFSaving.Transactions;Trusted_Connection=True;ConnectRetryCount=0"; using (var context = new BloggingContext( new DbContextOptionsBuilder() @@ -74,4 +74,4 @@ public class Blog public int BlogId { get; set; } public string Url { get; set; } } -} \ No newline at end of file +} diff --git a/samples/core/Saving/Transactions/CommitableTransaction.cs b/samples/core/Saving/Transactions/CommitableTransaction.cs index 9cd2e39ef1..d68e285fd8 100644 --- a/samples/core/Saving/Transactions/CommitableTransaction.cs +++ b/samples/core/Saving/Transactions/CommitableTransaction.cs @@ -10,7 +10,7 @@ public class CommitableTransaction public static void Run() { var connectionString = - @"Server=(localdb)\mssqllocaldb;Database=EFSaving.Transactions;Trusted_Connection=True"; + @"Server=(localdb)\mssqllocaldb;Database=EFSaving.Transactions;Trusted_Connection=True;ConnectRetryCount=0"; using (var context = new BloggingContext( new DbContextOptionsBuilder() @@ -76,4 +76,4 @@ public class Blog public int BlogId { get; set; } public string Url { get; set; } } -} \ No newline at end of file +} diff --git a/samples/core/Saving/Transactions/ControllingTransaction.cs b/samples/core/Saving/Transactions/ControllingTransaction.cs index 267fb9bd11..363c66346d 100644 --- a/samples/core/Saving/Transactions/ControllingTransaction.cs +++ b/samples/core/Saving/Transactions/ControllingTransaction.cs @@ -48,7 +48,7 @@ public class BloggingContext : DbContext protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder.UseSqlServer( - @"Server=(localdb)\mssqllocaldb;Database=EFSaving.Transactions;Trusted_Connection=True"); + @"Server=(localdb)\mssqllocaldb;Database=EFSaving.Transactions;Trusted_Connection=True;ConnectRetryCount=0"); } } @@ -57,4 +57,4 @@ public class Blog public int BlogId { get; set; } public string Url { get; set; } } -} \ No newline at end of file +} diff --git a/samples/core/Saving/Transactions/ExternalDbTransaction.cs b/samples/core/Saving/Transactions/ExternalDbTransaction.cs index df7da8a663..62fe8a4aa2 100644 --- a/samples/core/Saving/Transactions/ExternalDbTransaction.cs +++ b/samples/core/Saving/Transactions/ExternalDbTransaction.cs @@ -9,7 +9,7 @@ public class ExternalDbTransaction public static void Run() { var connectionString = - @"Server=(localdb)\mssqllocaldb;Database=EFSaving.Transactions;Trusted_Connection=True"; + @"Server=(localdb)\mssqllocaldb;Database=EFSaving.Transactions;Trusted_Connection=True;ConnectRetryCount=0"; using (var context = new BloggingContext( new DbContextOptionsBuilder() @@ -71,4 +71,4 @@ public class Blog public int BlogId { get; set; } public string Url { get; set; } } -} \ No newline at end of file +} diff --git a/samples/core/Saving/Transactions/ManagingSavepoints.cs b/samples/core/Saving/Transactions/ManagingSavepoints.cs index 38df73d7ba..20d8e47974 100644 --- a/samples/core/Saving/Transactions/ManagingSavepoints.cs +++ b/samples/core/Saving/Transactions/ManagingSavepoints.cs @@ -47,7 +47,7 @@ public class BloggingContext : DbContext protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder.UseSqlServer( - @"Server=(localdb)\mssqllocaldb;Database=EFSaving.Transactions;Trusted_Connection=True"); + @"Server=(localdb)\mssqllocaldb;Database=EFSaving.Transactions;Trusted_Connection=True;ConnectRetryCount=0"); } } @@ -56,4 +56,4 @@ public class Blog public int BlogId { get; set; } public string Url { get; set; } } -} \ No newline at end of file +} diff --git a/samples/core/Saving/Transactions/SharingTransaction.cs b/samples/core/Saving/Transactions/SharingTransaction.cs index d841b106c4..ae680054e4 100644 --- a/samples/core/Saving/Transactions/SharingTransaction.cs +++ b/samples/core/Saving/Transactions/SharingTransaction.cs @@ -11,7 +11,7 @@ public class SharingTransaction public static void Run() { var connectionString = - @"Server=(localdb)\mssqllocaldb;Database=EFSaving.Transactions;Trusted_Connection=True"; + @"Server=(localdb)\mssqllocaldb;Database=EFSaving.Transactions;Trusted_Connection=True;ConnectRetryCount=0"; using (var context = new BloggingContext( new DbContextOptionsBuilder() @@ -42,7 +42,7 @@ public static void Run() var blogs = context2.Blogs .OrderBy(b => b.Url) .ToList(); - + context2.Blogs.Add(new Blog { Url = "http://dot.net" }); context2.SaveChanges(); } diff --git a/samples/core/Schemas/Migrations/CustomOperation.cs b/samples/core/Schemas/Migrations/CustomOperation.cs index 4e5a6b4517..afa709dea2 100644 --- a/samples/core/Schemas/Migrations/CustomOperation.cs +++ b/samples/core/Schemas/Migrations/CustomOperation.cs @@ -74,7 +74,7 @@ private void Generate( internal class CustomOperationContext : DbContext { - private readonly string _connectionString = @"Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=Sample"; + private readonly string _connectionString = @"Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=Sample;ConnectRetryCount=0"; #region snippet_OnConfiguring protected override void OnConfiguring(DbContextOptionsBuilder options) diff --git a/samples/core/Schemas/Migrations/MigrationTableNameContext.cs b/samples/core/Schemas/Migrations/MigrationTableNameContext.cs index 1124346a58..8d0d343d78 100644 --- a/samples/core/Schemas/Migrations/MigrationTableNameContext.cs +++ b/samples/core/Schemas/Migrations/MigrationTableNameContext.cs @@ -4,7 +4,7 @@ namespace Migrations; public class MigrationTableNameContext : DbContext { - private readonly string _connectionString = @"Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=Sample"; + private readonly string _connectionString = @"Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=Sample;ConnectRetryCount=0"; #region TableNameContext protected override void OnConfiguring(DbContextOptionsBuilder options) @@ -12,4 +12,4 @@ protected override void OnConfiguring(DbContextOptionsBuilder options) _connectionString, x => x.MigrationsHistoryTable("__MyMigrationsHistory", "mySchema")); #endregion -} \ No newline at end of file +} diff --git a/samples/core/Schemas/Migrations/MyHistoryRepository.cs b/samples/core/Schemas/Migrations/MyHistoryRepository.cs index 55f3e1c7f7..a5b7413115 100644 --- a/samples/core/Schemas/Migrations/MyHistoryRepository.cs +++ b/samples/core/Schemas/Migrations/MyHistoryRepository.cs @@ -9,7 +9,7 @@ namespace Migrations; public class MyHistoryRepositoryContext : DbContext { - private readonly string _connectionString = @"Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=Sample"; + private readonly string _connectionString = @"Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=Sample;ConnectRetryCount=0"; #region HistoryRepositoryContext protected override void OnConfiguring(DbContextOptionsBuilder options) @@ -34,4 +34,4 @@ protected override void ConfigureTable(EntityTypeBuilder history) history.Property(h => h.MigrationId).HasColumnName("Id"); } } -#endregion \ No newline at end of file +#endregion diff --git a/samples/core/Spatial/SqlServer/Models/WideWorldImportersContext.cs b/samples/core/Spatial/SqlServer/Models/WideWorldImportersContext.cs index 6180a81ac6..ece5a8ddfd 100644 --- a/samples/core/Spatial/SqlServer/Models/WideWorldImportersContext.cs +++ b/samples/core/Spatial/SqlServer/Models/WideWorldImportersContext.cs @@ -13,7 +13,7 @@ internal class WideWorldImportersContext : DbContext protected override void OnConfiguring(DbContextOptionsBuilder options) => #region snippet_UseNetTopologySuite options.UseSqlServer( - @"Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=WideWorldImporters", + @"Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=WideWorldImporters;ConnectRetryCount=0", x => x.UseNetTopologySuite()); #endregion -} \ No newline at end of file +} diff --git a/samples/core/Testing/BloggingWebApi/Startup.cs b/samples/core/Testing/BloggingWebApi/Startup.cs index 617faedb9f..85dd5fd101 100644 --- a/samples/core/Testing/BloggingWebApi/Startup.cs +++ b/samples/core/Testing/BloggingWebApi/Startup.cs @@ -23,7 +23,7 @@ public void ConfigureServices(IServiceCollection services) services.AddDbContext( b => b.UseSqlServer( - @"Server=(localdb)\mssqllocaldb;Database=EFTestSample;Trusted_Connection=True")); + @"Server=(localdb)\mssqllocaldb;Database=EFTestSample;Trusted_Connection=True;ConnectRetryCount=0")); #region RegisterRepositoryInDI services.AddScoped(); @@ -42,4 +42,4 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env) app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); } -} \ No newline at end of file +} diff --git a/samples/core/Testing/BusinessLogic/BloggingContext.cs b/samples/core/Testing/BusinessLogic/BloggingContext.cs index 71649a16e6..be93d0a4cc 100644 --- a/samples/core/Testing/BusinessLogic/BloggingContext.cs +++ b/samples/core/Testing/BusinessLogic/BloggingContext.cs @@ -28,7 +28,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) if (!optionsBuilder.IsConfigured) { optionsBuilder.UseSqlServer( - @"Server=(localdb)\mssqllocaldb;Database=EFProviders.InMemory;Trusted_Connection=True"); + @"Server=(localdb)\mssqllocaldb;Database=EFProviders.InMemory;Trusted_Connection=True;ConnectRetryCount=0"); } } #endregion @@ -43,4 +43,4 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) _modelCustomizer(this, modelBuilder); } } -} \ No newline at end of file +} diff --git a/samples/core/Testing/TestingWithTheDatabase/TestDatabaseFixture.cs b/samples/core/Testing/TestingWithTheDatabase/TestDatabaseFixture.cs index 843c6700d7..7b396bc1f8 100644 --- a/samples/core/Testing/TestingWithTheDatabase/TestDatabaseFixture.cs +++ b/samples/core/Testing/TestingWithTheDatabase/TestDatabaseFixture.cs @@ -6,7 +6,7 @@ namespace EF.Testing.IntegrationTests; #region TestDatabaseFixture public class TestDatabaseFixture { - private const string ConnectionString = @"Server=(localdb)\mssqllocaldb;Database=EFTestSample;Trusted_Connection=True"; + private const string ConnectionString = @"Server=(localdb)\mssqllocaldb;Database=EFTestSample;Trusted_Connection=True;ConnectRetryCount=0"; private static readonly object _lock = new(); private static bool _databaseInitialized; @@ -39,4 +39,4 @@ public BloggingContext CreateContext() .UseSqlServer(ConnectionString) .Options); } -#endregion \ No newline at end of file +#endregion diff --git a/samples/core/Testing/TestingWithTheDatabase/TransactionalTestDatabaseFixture.cs b/samples/core/Testing/TestingWithTheDatabase/TransactionalTestDatabaseFixture.cs index 2f26f78d4f..0dba2699a7 100644 --- a/samples/core/Testing/TestingWithTheDatabase/TransactionalTestDatabaseFixture.cs +++ b/samples/core/Testing/TestingWithTheDatabase/TransactionalTestDatabaseFixture.cs @@ -7,7 +7,7 @@ namespace EF.Testing.IntegrationTests; #region TransactionalTestDatabaseFixture public class TransactionalTestDatabaseFixture { - private const string ConnectionString = @"Server=(localdb)\mssqllocaldb;Database=EFTransactionalTestSample;Trusted_Connection=True"; + private const string ConnectionString = @"Server=(localdb)\mssqllocaldb;Database=EFTransactionalTestSample;Trusted_Connection=True;ConnectRetryCount=0"; public BloggingContext CreateContext() => new BloggingContext( @@ -45,4 +45,4 @@ public void Cleanup() public class TransactionalTestsCollection : ICollectionFixture { } -#endregion \ No newline at end of file +#endregion