I’m using ASP.NET MVC 3.0 Database First approach with EF 4.x. Models are generated with EF 4.x DBContext Generator. Now I want to change model structure but don’t want to change existing model because if database is modified I have to generate model again so the changes will be gone. I think it should be done by overriding partial classes but not clear. Is there any example to do it? what is the best way to implement it?
Edit: I have to add some additional validations in some Models, not all. I want to create independent models which overrides the generated classes and in case if EF models are regenerated there is no harm on our customized models.
You can create partial classes like this
namespace MyProject.Data{
public partial class User{}
}
but your partial class should be the same namespace of EF created classes