문제

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top