Skip to content
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

Multiple constructors in DbContext not allowed #1014

Closed
SandroRiz opened this issue Jun 7, 2021 · 3 comments
Closed

Multiple constructors in DbContext not allowed #1014

SandroRiz opened this issue Jun 7, 2021 · 3 comments

Comments

@SandroRiz
Copy link

In a Blazor Server Side project it is suggested to not use DbContext like in asp.net core (neither of the three AddSingleton/Scoped/Transient are ok) but instead use it with a Factory

Doing so, the DbContext cannot have multiple constructor like the one auto-generated. Commenting the first ctor without parameters resolves the issue, but you have to do every time you redo the reverse engineering

Steps to reproduce

Create Blazor server side solution adding the dbcontext in startup.cs with
services.AddDbContextFactory(options => options.UseSqlServer(cs));

Use it in a razor component with
[Inject] public IDbContextFactory ContextFactory { get; set; }
var MyRepoService = new MyRepoService (ContextFactory.CreateDbContext());

Further technical details

EF Core Power Tools version: 2.5.665
Database engine: SQL Server

Visual Studio version: 2019 16.10

See error
localhost-1623047631465.log

@ErikEJ
Copy link
Owner

ErikEJ commented Jun 7, 2021

I think this is a bug, that is already fixed in EF Core 6
@ajcvickers - maybe you can confirm?

@ErikEJ
Copy link
Owner

ErikEJ commented Jun 17, 2021

Duplicate of #991 - will be fixed in 6.0

@ErikEJ ErikEJ closed this as completed Jun 17, 2021
@ErikEJ
Copy link
Owner

ErikEJ commented Jul 11, 2021

Fixed in latest daily buidl: b85c77d

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants