One thing is driving me crazy right now.
My (Database-first) EF-Model needs a dynamic connection string (IP-Adress of Server might change once in a while).
So in older EF-Versions you could pass a connection-string via constructor, but that is not possible in 5.0 as is seems.
What I have read so far, you could change your datatemplate, but that will be overwritten each time you re-generate your model etc., so not the best way to do it.
Another thing is the SQLConnectionFactory, but that does not seem to work at all
(Database.DefaultConnectionFactory = new SqlConnectionFactory( ... )
seems to be ignored completely).
What would be the right approach for that?
EF Core 5.0 requires a . NET Standard 2.1 platform.
The next planned stable release is EF Core 8.0, or just EF8, scheduled for November 2023.
Keep using EF6 if the data access code is stable and not likely to evolve or need new features. Port to EF Core if the data access code is evolving or if the app needs new features only available in EF Core. Porting to EF Core is also often done for performance.
As petro mentions, you could create a partial class with the constructor you want.
For instance:
public partial class MyContext : DbContext
{
public MyContext(string connectionString) : base(connectionString) {}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With