Im sorry if this is in the wrong place, however I think it is.
So I when creating an MVC3 internet application I used a database first method and my classes were generated for me. I am new to MVC3 and fairly new to c# and visual studio although I do have a little experience.
The auto-generated code warns that editing may cause unexpected results and the changes will be removed if the code is regenerated. As I understand it that means changes to the database, rerunning the tt files or updating the model.
However is it ok practice to edit it, and just keep a track of changes incase i need to regenerate, or is there a better way to go about it?
Thanks for any help.
The classes generated should be partial
classes so you should be able to externally manage enhancements by making your own partial
class with the same namespace and name.
In the model first approach, using the default code generation strategy on you EDMX
file, the classes generated for you DbContext
and Entity
classes are all partial classes.
So, depending on your type of changes, if you want to extend these generated classes, just create a new partial class with you custom code in it. Your partial's will not be overwritten by the code generator.
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