-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Closed
Milestone
Description
File a bug
After upgrading Microsft.EntityFrameworkCore related nugets in my project from to 8.0.10 (from 8.0.8), my application fails at runtime as well as while running migrations on the attached repro repository. The error I'm getting:
Unable to create a 'DbContext' of type ''. The exception 'The convention invocations have reached the recursion limit. This is likely an issue in Entity Framework, please file an issue at https://go.microsoft.com/fwlink/?linkid=2142044.' was thrown while attempting to create an instance. For the different patterns supported at design time, see https://go.microsoft.com/fwlink/?linkid=851728
Include your code
https://github.com/sharkk121/EfCoreBug/tree/master
dotnet ef migrations add Test
It completes without exceptions on 8.0.8. As a workaround you can also uncomment lines 19 and 20 in Program.cs as well as uncomment lines 36 and 42 in TestDbContext.cs (while commenting 37 and 43)
Include stack traces
Microsoft.EntityFrameworkCore.Design.OperationException: Unable to create a 'DbContext' of type ''. The exception 'The convention invocations have reached the recursion limit. This is likely an issue in Entity Framework, please file an issue at https://go.microsoft.com/fwlink/?linkid=2142044.' was thrown while attempting to create an instance. For the different patterns supported at design time, see https://go.microsoft.com/fwlink/?linkid=851728
---> System.InvalidOperationException: The convention invocations have reached the recursion limit. This is likely an issue in Entity Framework, please file an issue at https://go.microsoft.com/fwlink/?linkid=2142044.
at Microsoft.EntityFrameworkCore.Metadata.Conventions.Internal.ConventionDispatcher.ConventionBatch.Run()
at Microsoft.EntityFrameworkCore.Metadata.Conventions.Internal.ConventionDispatcher.ConventionBatch.Dispose()
at Microsoft.EntityFrameworkCore.Metadata.Builders.CollectionCollectionBuilder.UsingEntity(String joinEntityName, Type joinEntityType, Func`2 configureRight, Func`2 configureLeft)
at Microsoft.EntityFrameworkCore.Metadata.Builders.CollectionCollectionBuilder`2.Using[TJoinEntity](String joinEntityName, Func`2 configureRight, Func`2 configureLeft)
at Microsoft.EntityFrameworkCore.Metadata.Builders.CollectionCollectionBuilder`2.UsingEntity[TJoinEntity](Func`2 configureRight, Func`2 configureLeft)
at Microsoft.EntityFrameworkCore.Metadata.Builders.CollectionCollectionBuilder`2.UsingEntity[TJoinEntity](Func`2 configureRight, Func`2 configureLeft, Action`1 configureJoinEntityType)
at EfCoreBug.PostsConfiguration.Configure(EntityTypeBuilder`1 builder) in H:\source\EfCoreBug\TestDbContext.cs:line 29
at Microsoft.EntityFrameworkCore.ModelBuilder.ApplyConfiguration[TEntity](IEntityTypeConfiguration`1 configuration)
at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
at System.Reflection.MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object obj, Span`1 copyOfArgs, BindingFlags invokeAttr)
--- End of inner exception stack trace ---
at Microsoft.EntityFrameworkCore.Design.Internal.DbContextOperations.CreateContext(String contextType)
at Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations.AddMigration(String name, String outputDir, String contextType, String namespace)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.AddMigrationImpl(String name, String outputDir, String contextType, String namespace)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.AddMigration.<>c__DisplayClass0_0.<.ctor>b__0()
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.<>c__DisplayClass3_0`1.<Execute>b__0()
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
Include verbose output
PS H:\source\EfCoreBug> dotnet ef migrations add Test --verbose
Using project 'H:\source\EfCoreBug\EfCoreBug.csproj'.
Using startup project 'H:\source\EfCoreBug\EfCoreBug.csproj'.
Writing 'H:\source\EfCoreBug\obj\EfCoreBug.csproj.EntityFrameworkCore.targets'...
dotnet msbuild /target:GetEFProjectMetadata /property:EFProjectMetadataFile=C:\Users\sharkk121\AppData\Local\Temp\tmpsxoyop.tmp /verbosity:quiet /nologo H:\source\EfCoreBug\EfCoreBug.csproj
Writing 'H:\source\EfCoreBug\obj\EfCoreBug.csproj.EntityFrameworkCore.targets'...
dotnet msbuild /target:GetEFProjectMetadata /property:EFProjectMetadataFile=C:\Users\sharkk121\AppData\Local\Temp\tmpxyon0w.tmp /verbosity:quiet /nologo H:\source\EfCoreBug\EfCoreBug.csproj
Build started...
dotnet build H:\source\EfCoreBug\EfCoreBug.csproj /verbosity:quiet /nologo /p:PublishAot=false
Build succeeded.
0 Warning(s)
0 Error(s)
Time Elapsed 00:00:00.72
Workload updates are available. Run `dotnet workload list` for more information.
Build succeeded.
dotnet exec --depsfile H:\source\EfCoreBug\bin\Debug\net8.0\EfCoreBug.deps.json --additionalprobingpath C:\Users\sharkk121\.nuget\packages --runtimeconfig H:\source\EfCoreBug\bin\Debug\net8.0\EfCoreBug.runtimeconfig.json C:\Users\sharkk121\.dotnet\tools\.store\dotnet-ef\8.0.10\dotnet-ef\8.0.10\tools\net8.0\any\tools\netcoreapp2.0\any\ef.dll migrations add Test --assembly H:\source\EfCoreBug\bin\Debug\net8.0\EfCoreBug.dll --project H:\source\EfCoreBug\EfCoreBug.csproj --startup-assembly H:\source\EfCoreBug\bin\Debug\net8.0\EfCoreBug.dll --startup-project H:\source\EfCoreBug\EfCoreBug.csproj --project-dir H:\source\EfCoreBug\ --root-namespace EfCoreBug --language C# --framework net8.0 --nullable --working-dir H:\source\EfCoreBug --verbose
Using assembly 'EfCoreBug'.
Using startup assembly 'EfCoreBug'.
Using application base 'H:\source\EfCoreBug\bin\Debug\net8.0'.
Using working directory 'H:\source\EfCoreBug'.
Using root namespace 'EfCoreBug'.
Using project directory 'H:\source\EfCoreBug\'.
Remaining arguments: .
Finding DbContext classes...
Finding IDesignTimeDbContextFactory implementations...
Finding application service provider in assembly 'EfCoreBug'...
Finding Microsoft.Extensions.Hosting service provider...
No static method 'CreateHostBuilder(string[])' was found on class 'Program'.
No application service provider was found.
Finding DbContext classes in the project...
Found DbContext 'TestDbContext'.
Using context 'TestDbContext'.
Microsoft.EntityFrameworkCore.Design.OperationException: Unable to create a 'DbContext' of type ''. The exception 'The convention invocations have reached the recursion limit. This is likely an issue in Entity Framework, please file an issue at https://go.microsoft.com/fwlink/?linkid=2142044.' was thrown while attempting to create an instance. For the different patterns supported at design time, see https://go.microsoft.com/fwlink/?linkid=851728
---> System.InvalidOperationException: The convention invocations have reached the recursion limit. This is likely an issue in Entity Framework, please file an issue at https://go.microsoft.com/fwlink/?linkid=2142044.
at Microsoft.EntityFrameworkCore.Metadata.Conventions.Internal.ConventionDispatcher.ConventionBatch.Run()
at Microsoft.EntityFrameworkCore.Metadata.Conventions.Internal.ConventionDispatcher.ConventionBatch.Dispose()
at Microsoft.EntityFrameworkCore.Metadata.Builders.CollectionCollectionBuilder.UsingEntity(String joinEntityName, Type joinEntityType, Func`2 configureRight, Func`2 configureLeft)
at Microsoft.EntityFrameworkCore.Metadata.Builders.CollectionCollectionBuilder`2.Using[TJoinEntity](String joinEntityName, Func`2 configureRight, Func`2 configureLeft)
at Microsoft.EntityFrameworkCore.Metadata.Builders.CollectionCollectionBuilder`2.UsingEntity[TJoinEntity](Func`2 configureRight, Func`2 configureLeft)
at Microsoft.EntityFrameworkCore.Metadata.Builders.CollectionCollectionBuilder`2.UsingEntity[TJoinEntity](Func`2 configureRight, Func`2 configureLeft, Action`1 configureJoinEntityType)
at EfCoreBug.PostsConfiguration.Configure(EntityTypeBuilder`1 builder) in H:\source\EfCoreBug\TestDbContext.cs:line 29
at Microsoft.EntityFrameworkCore.ModelBuilder.ApplyConfiguration[TEntity](IEntityTypeConfiguration`1 configuration)
at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
at System.Reflection.MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object obj, Span`1 copyOfArgs, BindingFlags invokeAttr)
--- End of inner exception stack trace ---
at Microsoft.EntityFrameworkCore.Design.Internal.DbContextOperations.CreateContext(String contextType)
at Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations.AddMigration(String name, String outputDir, String contextType, String namespace)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.AddMigrationImpl(String name, String outputDir, String contextType, String namespace)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.AddMigration.<>c__DisplayClass0_0.<.ctor>b__0()
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.<>c__DisplayClass3_0`1.<Execute>b__0()
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
Unable to create a 'DbContext' of type ''. The exception 'The convention invocations have reached the recursion limit. This is likely an issue in Entity Framework, please file an issue at https://go.microsoft.com/fwlink/?linkid=2142044.' was thrown while attempting to create an instance. For the different patterns supported at design time, see https://go.microsoft.com/fwlink/?linkid=851728
Include provider and version information
EF Core version: 8.0.10
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .NET 8.0
Operating system: Windows 11 23H2 22631.4249
IDE: (e.g. Visual Studio 2022 17.11.5)