-
Notifications
You must be signed in to change notification settings - Fork 60
Setting to generate context with one single constructor for pooling [FEATURE REQUEST] #72
Comments
To be honest I don't understand why the context in EF Core might need a default constructor without parameters. |
Now that you mention it, neither do I. I'm removing that. If anyone wants it back, it can be added to their partial. I'll put something in the docs about that - something nags at me that I put that there for a reason but, of course, didn't document it at the time so don't remember why now. (https://i.redd.it/hwqj7yx9vm211.jpg) |
Thanks for your support! I tried to test this but something went wrong :( 1.2.7.2 version is not working: I reverted to 1.2.7.1 and all is good... |
There was an issue with the build server causing the vsix to have some issues. I've since rebuilt and verified that it runs in VS2017 and VS2019. The new build is posted in the marketplace and here on github with the same version number. Please give that a go, and my apologies for the problems. |
Yes, now it's working as expexted. Thank you! |
Generating a migration without a parameterless constructor results in an error: Adding the empty constructor back fixes this problem. Where in the docs have you added the information? |
@rlarik, thanks for the info! I forgot about that because I use ASP.NET Core framework :) In ASP.NET Core scenario both parameterless constructor and OnConfiguring() method are not needed. |
So, maybe it would be more appropriate to add a setting regarding the ASP.NET Core framework:
Default value is false. P.S. |
EF Core supports context poling by calling
AddDbContextPool<>()
instead ofAddDbContext<>()
insideConfigureServices()
method. But this requires context to have only one single constructor with options parameter:InvalidOperationException: The DbContext of type 'DataContext' cannot be pooled because it does not have a single public constructor accepting a single parameter of type DbContextOptions.
To workaround this I commented the following lines in local copy of
EFCoreDesigner.ttinclude
file:// Output("/// <inheritdoc />");
// Output($"public {modelRoot.EntityContainerName}() : base()");
// Output("{");
// Output("}");
// NL();
It would be great to add setting for that in Entity Context section of diagram properties :)
The text was updated successfully, but these errors were encountered: