I have a Entity Framework class that was derived from the database layout. I was wondering if there was any problems by extending the class by creating another cs file and using the same public partial class to add the additional properties?

Much like you would do when creating a file for data annotations. I have tested and it works for my MVC application. It allows me to pass some dynamic properties to the view model while still using the original model from EF 'and additional file I created'.

Does this pose any problems, or is there a better solution?

1 Answer 1


This is the preferred method of extending the EF data classes.

You can add almost anything. I had a situation where I needed to use different annotations (replacements for the validation, as the defaults weren't sufficient for my needs).

Microsoft provides plenty of examples to do this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.