I have this edmx model (see below) and I would like to add an extra association from Order
to Worker
*-1
as shown by the red line, problem is, the database has already got lots of data that I don't want to wipe, is it possible to add do this without recreating the tables?

- 5,368
- 18
- 64
- 133
2 Answers
Just because you have used Entity Designer to start with doesn't mean that you have to totally recreate your database each time.
If you generate the SQL from your changed model, you should be able to find the part referring to your new relationship easily enough. That is the only part you need to run against your database- just split it out into it's own file. If in doubt save a copy of the old SQL file, add your relationship, generate the new file and create a diff to be sure.
Alternatively if you have a good understanding of how EF represents data and relationships you can probably change the database manually. As long as the database and the model are accurately coherent, EF doesn't really care how the database got that way.

- 11,018
- 13
- 64
- 112
Simply let EF to create a new database in your development environment and use some database diff. tool to get change script from the old database to a new one. VS 2010 Premium and Ultimate contains this diff. tool and you can even use it directly from EDMX designer if you install Database Generation tools power pack.
Another popular diff tool is for example SQL Compare by RedGate.

- 360,892
- 59
- 660
- 670
-
Hi I downloaded this addon some time ago but couldnt figure out which option I needed. Any good tutorials you can recommend for what I need to do? Or maybe you can give me some keywords I can search up. – sprocket12 Jun 21 '12 at 10:46
-
So you should try them all to learn something new ... But I really don't understand how you could miss [Generate Migration T-SQL](http://stackoverflow.com/questions/4221938/how-to-do-migration-when-generate-database-from-model-in-entity-framework-model) – Ladislav Mrnka Jun 21 '12 at 10:53