Closed andy-clymer closed 3 years ago
Same here since upgrading from 5 to 6.
Is this fixed in the latest EF Core 6.0.0 for sql-server? Couse I'm facing it too since I upgraded to 6
@mahyar1386 The fix will be included in the 6.0.1 patch, as indicated by the milestone. The fix is already included in the latest daily build.
@ajcvickers I'm not seeing any 6.0.1-* builds in the dotnet6 or dotnet7 nuget repositories, can you clarify how we can get the fix for this issue; also, is there an estimate for when 6.0.1 will be available?
To temporarily work around this issue until the release of 6.0.1 is made available, I set the MaxBatchSize to 1 in the Sql Server configuration for EF.
@failwyn Unfortunately, patches are not included in the daily builds. The 7.0.0 builds contain this fix. The patch is scheduled for release in the coming days.
To temporarily work around this issue until the release of 6.0.1 is made available, I set the MaxBatchSize to 1 in the Sql Server configuration for EF.
For anyone else struggling with this, @andy-clymer's workaround worked for us as well. Add o => o.MaxBatchSize(1)
to your AddSqlServer
configuration. Thanks, @andy-clymer!
FYI for those impacted by this issue: EF Core 6.0.1 is now available from NuGet.
Description
There is an issue when adding new entities of different types to the context and calling save changes at the end when one entity only has a single record to add and another entity has more than two records to add. I followed a variation of this example to produce the issue, and have included the demo application for reproducing the problem.
Problem Code Snippet
Stack trace
Exception: An error occurred while saving the entity changes. See the inner exception for details.
Inner Exception: The variable name '@instered0' has already been declared. Variable names must be unique withing a query batch or stored procedure.
Include provider and version information
EF Core version: 6.0.0 Database provider: Microsoft.EntityFrameworkCore.SqlServer Target framework: .NET 6.0 Operating system: Windows 11 Pro IDE: Visual Studio Enterprise 2022 (64-bit) 17.0.0
Sample.Api.zip