There are many ways to implement the entity framework. I chose to add a link to the template in a different project. This implementation can be found here.
Now this article doesn’t describe in detail what to do when the database changes. This can be a very pain full operation if you have to figure it out yourself. That’s why I wrote this post.
In this case I chose to change an existing database table and add a new table to the database.
I divided the solution in 3 layers, the database layer, a process layer and a GUI. In between you’ll find the entities going from top to bottom. So no use of DTO or any kind of mapping.
The edmx model is located in the DataLayer. Also the generated tt files for the self-tracking entities is located there. In the CMDBProcessLayer I added the context as link and in the CMDBentities project I added the self-tracking objects as linked files.
Let go to the update process.
Step 1 is off course update the database.
Step 2: Remove the linked files to the entities and the context.
Step 3: Update the database model (edmx file)
after: (Do not forget to save the model, else you could get problems creating the code generation items)
Step 4: Delete the old tt files in the DataLayer
Step 5: Generate new tt files
Step 6: Turn off code generation on the entity model.tt file
Step 7: Delete all remaining file generated by the entities.tt file:
Stap 8: repeat step 6 and 7 for the context.tt file
Step 9: Add the Entity.tt file to your entities shared projects. (If you do not see the files, choose 'All Files' in the file filter box on your lower right.)
Step 10: add the context.tt file as linked file to the process layer
Step 11 (Last step): Change the namespace of context.tt file to the namespace of the shared entities project.
Now you can build and you have the new data structure.