I am using Entity Framework to do the ORM in .NET project. The problem I am facing is that when the database schema changes, there is no proper mechanism to update the edmx file.
For example, If there is a column called "Salary", and I change it to "EmpSalary", then when I update the edmx from visual studio and it shows me two columns in the class - Salary and EmpSalary.
One way I figured out is to delete the entire edmx file and regenerate it. But then what if I have manually renamed the navigation properties in the model? I will lose them and I have to recreate them which is a painful thing to do every time.
Any best practices in this area?
Thanks
The approach I used with Linq To SQL (which has the same issue) is to script my manual changes to the xml file so that I could reapply them after re-running generation process. You can generate a class library for editing the edmx file using Linq To Xsd. See http://www.adverseconditionals.com/2008/05/scripting-changes-to-linq-to-sql-dbml.html for a bit more detail
In the EF1 designer, the "Update Model From Database" function is broken for a lot of situations. I've been working with EF1 for about a year now. Problems using the EF1 designer have cost me days of time so as far as I'm concerned the best practice is to manually edit the EDMX XML yourself.
For tricky stuff, create a new model containing the new tables / columns / relationships / views you want and then copy-paste the XML from the new EDMX into your existing XML.
Some things it breaks when you use "Update Model From Database"
I'm sure there are more, but this was enough for me to stop using it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With