Topic:   How to force DI to use request specific version of assembly for DbContext instance creation ? Is it possible to create custom scoped service factory or use some other DI library ?
Mar 04, 2021 11:14 2 Replies 497 Views TEJA

How to force DI to use request specific version of assembly for DbContext instance creation ?

Is it possible to create custom scoped service factory or use some other DI library ?

It looks like .NET 5 loads DbContext.dll on first use and does not allow to use different versions. This is ASP.NET 5 MVC Core application using EF Core with Npgsql data provider.

Prev Next
Topic Replies (2)
  1. 1
    idnkx user

    PARTH

    You can create a custom scoped service factory to solve your purpose.

    1
    idnkx user

    SAI

    Instead of injecting a dbcontext instance, you should inject a factory. The factory could be as simple as a dictionary of dbcontext s keyed by a version identifier.
    Note: unless your versions implemented a common interfaces you will need to use reflection to call the methods.

Leave a Reply
Guest User

Not sure what course is right for you?

Choose the right course for you.
Get the help of our experts and find a course that best suits your needs.


Let`s Connect