Closed seancpeters closed 2 years ago
@seancpeters Can you provide some details as to why you are calling EF internal APIs?
The public API to do this is DbContextActivator.CreateInstance()
The call to this API is part of aspnet/scaffolding, here: https://github.com/aspnet/Scaffolding/blob/master/src/VS.Web.CG.EFCore/EntityFrameworkModelProcessor.cs# At line 404.
I don't know the historical context of why scaffolding is creating db contexts in this manner, as opposed to some other way.
Good time to fix aspnet/Scaffolding#681 and see if it still fails?
@bricelam - Thank you! This appears to have fixed the problem. Looking at history, it seems that the original fix never got merged, or got lost somewhere along the way.
Describe what is not working as expected. I'm getting seemingly inconsistent behavior when calling
Microsoft.EntityFrameworkCore.Design.Internal.DbContextOperations.CreateContext(String contextType)
via aspnet/scaffolding of Razor Pages (CRUD) for a 2.1 project. If you are seeing an exception, include the full exceptions details (message and stack trace).It seems to work fine in most cases - these cases work:
The combination which fails is:
The difference between the projects would be that the individual auth projects already contain an IdentityDbContext, but this scaffolding gesture would create a DbContext-derived class.
Steps to reproduce
Include a complete code listing (or project/solution) that we can run to reproduce the issue.
Partial code listings, or multiple fragments of code, will slow down our response or cause us to push the issue back to you to provide code to reproduce the issue.
I'm attaching 4 sample projects, each in their own zip. They're named to reflect the 4 cases mentioned above.
Core21IndAuth.zip Core21NoAuth.zip Framework21IndAuth.zip Framework21NoAuth.zip
Further technical details
EF Core version: 2.1.4 Database Provider: Microsoft.EntityFrameworkCore.SqlServer 2.1.4 Operating system: Windows IDE: Visual Studio 2017 15.9.0 Preview 3.0 [28128.56.d15.9]