My project:
- I have a c# data project (currently in TFS, but it will be moved to git) with multiple branches.
- Most branches have their own development database (on an azure SQL server)
- I am using Entity Framework 6 (Database first with edmx Model, created in the EF4 days)
- The database project is used by multiple solutions / starting projects (a hosting project as main project)
I want to automatically have the correct development DB in the EF "Update model from database" dialog. The connection string that should be used must be in the hosting project web.config (the app itself runs on azure, so the web.config connection string is never used during runtime)
Currently I have a process to:
- Update the web.config (and all other configs) with a connection string to the specific branch database
- I check that change into Source Control
- I do a "discard merge" to the main branch (marking the changes as merged without changing the "main" database connection or other dev connections if merging that checkin to other branches)
This process is far from ideal.
I tested with external config files (using the "file" or "configSource" attributes) but that:
- Cannot include a file in the parent directory (i would have to create a DatabaseConnection.config file for each project instead of only one central one)
- still has the problem if either checking into SC (no real win) or a process to create the file (in the pre-build event). This would require a build before I can update the database (in a new branch / after switching branches when using git?)
So still not ideal.
I did not find anything about the database designer (update model wizard) able to read the connection from somewhere other than the start project config file (?)
I also know that many people have databases per developer and not per branch, but I need the branch databases in this case. I also only have problems with using the correct branch database when updating the model. The correct branch / development database is chosen automatically during runtime (naming convention)
-> Does anybody has any hints about using
- Multiple .config files / projects
- with one database per branch (mostly)
- with often branch switches
- or any way to tell the EF6 "Update model from database" wizard where / how to get the connection string from another source
Converting to "Model first" is also not really possible at the moment because of the size of the projects and deploy mechanics