Open Driedas opened 1 year ago
The question was raised #26630; the interface used to be covariant, but adding the async method removed that. We should fix the docs.
right, thanks for the quick response, I did try looking for existing issues, but probably only open issues by mistake 👍
In the mean time I've implemented a workaround, coincidentally the same approach used in the linked issue, so we will stick with that.
Thanks...
Re-opening to fix docs.
According to the official documentation of IDbContextFactory , the TContext parameter should be covariant:
However, that is not the case in the source code
Is this just a case of a copy paste issue from the documentation of Entity Framework, where the interface actually was covariant? Is there a reason why this is not supported in EF core? To me it looks like a textbook example of where covariance should work and enable to dynamically provide derived DbContext implementations with different configurations. For example we are using a derived DbContext in automated tests with certain entities configured slightly differently (e. g. sql server variant columns)
TLDR: The below code should work according to the documentation, and did work in old EF, but does not in EF core