-
-
Notifications
You must be signed in to change notification settings - Fork 306
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ContextFactory - 'Multiple constructors accepting all given argument types have been found #991
Comments
Which EF Core version? |
EF Core 5.0.6 |
Looks like it is an EF Core bug: dotnet/efcore#24124 |
Ok. Thank you for your response. I will look for another solution. |
Manually remove the constructor?? |
Fixed in latest daily buidl: b85c77d |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have a Blazor project and I'm using a context class generated with the "Reverse Engeneer" option.
In use the following DbContextFactory Service in the startup class.
....
services.AddDbContextFactory(options => options
.UseSqlServer(
Configuration.GetConnectionString("MyDbConnection"),
o => o.EnableRetryOnFailure())
.EnableSensitiveDataLogging(true)
.EnableDetailedErrors(true));
services.AddScoped(p =>
p.GetRequiredService<IDbContextFactory>().CreateDbContext()
);
...
If I start the programm, the instruction
services.AddScoped(p =>
p.GetRequiredService<IDbContextFactory>().CreateDbContext()
);
produces the following error:
System.InvalidOperationException: 'Multiple constructors accepting all given argument types have been found in type 'MyContext'. There should only be one applicable constructor.'
If I remove the empty default constructor from the generated class, everything works.
Is it possible to prevent the creation of the default constructor?
Further technical details
EF Core Power Tools version: 2.5.659
Database engine: SQL Server
Visual Studio version: 16.9.6
The text was updated successfully, but these errors were encountered: