What is the meaning of IDbContextFactory <T> in First Code Migrations?

Following How do I insert a connection string into an IDbContextFactory instance? and a few mostly similar questions, I wonder what the point is IDbContextFactory<T>for Entity Framework migration.

According to MSDN, IDbContextFactory<T>we are talking about development-time support , which actually does not seem particularly relevant for the first code conversions.

Any factory classes implemented must implement the default constructor itself (which is used by EF / Migrations) and must implement a common method T Create(). This is just a repeating abstraction, I don’t see that it adds anything (maybe this is necessary for design-based approaches).

This means that there is no way to make any constructor injection, and this means that I can not really use it in reality, since various parameters (including, but not limited to, are nameOrConnectionStringunknown until runtime). See Also, Entity Framework 4.3.1 migrations always call the default constructor and ignore the connection string and Manually provide a DbContext for DbMigrator . A bunch of hacks.

With EF, in particular, IoCin general, and Dependency Injectionusually always seems thoughtful, if at all possible.

+4
source share

Source: https://habr.com/ru/post/1527351/


All Articles