I hope someone can help me because it seems like I'm completely stuck.
For upcoming projects in our company, we would like to use Entity Framework 5 with the first approach to the code. I played for a while, and every time I try to use EF with our existing libraries, I fail because it seems that EF is very dependent on the existing app.config.
Our company has a database library that allows us to connect to various data sources and database technologies, taking advantage of MEF (managed extensibility) for database providers. I just need to pass some database parameters, such as the host (or file), directory, user credentials and the name of the database provider, the library looks for the appropriate plugin and returns me a custom connection string or IDbConnection. We would like to use this library together with EF, because it allows us to be flexible as to which database we use and to modify the database at runtime.
So. I saw that a typical DbContext object does not accept any parameters in the constructor. It automatically searches for the appropriate connection string in app.config. We don’t like such things, so I changed the default constructor to take the DbConnection object, which is passed to the DbContext base class. No deal.
Problems arise when changing the first code model. EF automatically notices this and searches for migration / configuration classes. But: a typical migration class requires a constructor with no default parameters for the context! What a pity!
So, we create our own migration class using the IDbContextFactory interface. But then again, it looks like this IDbContextFactory needs a constructor without parameters, otherwise I cannot add migrations or update the database.
, , , . : , , .
, , EF - app.config. , , app.config !
?