Quantcast
Channel: Entity Framework
Viewing all articles
Browse latest Browse all 10318

Closed Task: Removing/re-adding EF nuget package updates app.config, which can be confusing if code based configuration is used [797]

$
0
0
Per current design of EF, many configuration settings can be configured via both app.config and code based config (DbConfiguration.) App.config based configuration has priority over code based configuration.

One example where this has confused me while testing various scenarios is the DefaultConnectionFactory.

I have a code based configuration which sets DefaultConectionFactory to LocalDbConnectionFactory:

```
public class MyConfiguration : DbConfiguration
{
public MyConfiguration()
{
SetDefaultConnectionFactory(new LocalDbConnectionFactory("v11.0"));
}
}
```


From app.config, I removed (commented out) the relevant section, which sets SqlConnectionFactory as the default:

`<!--<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />-->`

If I remove/re-add EF nuget package to the project again (which is common during testing), this section gets automatically added to app.config file. Unless I remember to go back and remove it again, my database will be in SqlExpress, while I (incorrectly) expect it to be LocalDb, based on the code I'm seeing on my screen.


Perhaps we can detect that there's code based configuration, and warn the user that their app.config is being updated, and she should probably take an action?

Viewing all articles
Browse latest Browse all 10318

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>