Tips on Updating existing EF models to EF 4.0
(Courtesy RIA Services QA)
· Recommended Steps:
o Create a separate project
o Add new EDMX models from the current database and let the framework naturally auto-generate all the names first.
§ Remember to leave this option checked (the default):
o Change the global names from UI first:
§ Entity Container Name
§ Custom Tool Namespace
o Then do a replace from the new model to the old one (Tip: Pick up your favorite diff tool for this).
§ Some models have clear changes that were easily matched
§ Some models are generated with disordered properties. In such cases, one has to copy everything and rely on the following steps to update them. (Recommended)
o Save and try to open the edmx designer
§ If there are some changes not made correctly, VS won’t open the designer and will identify the error. Fix all errors.
o Re-Compile the Server project
§ The existing DomainServices classes will show errors for any changed names that were not correct.
§ To further fix the names:
· Open the EDMX model browser
· Based on the compiler error messages, check the corresponding name in Entity Types, Associations, EntityContainer.EntitySets, Association Sets and Model.Store Tables and make sure that the new version matches the old ones.
o After fixing all the errors, the update is completed.
o If possible, consider using the new names and update your DomainServices instead of changing the model.
o If you have to, let the designer do the right thing for you. Try NOT touch the edmx file manually, unless you have to.