Suppose I have a table with whole bunch of fields and an EF entity generated for it. Suppose I want to show an edit form for this entity, BUT with an extra field that doesn’t directly map to the table.
So I create a model class that inherits my entity class and my field to it. So far so good.
The issue is that now I have to copy every single field from the entity object to the model object when returning a view and the other way around when saving data. Surely there is a cleaner way to do this?
Specific example would be a user administration form and extra fields would be password and confirm password fields, which are stored in the Membership table.
It’s good practice to separate between data-transfer objects used for communicating between application tiers such as UI, and raw entities connected to the storage. Yes, you’ll need to copy fields back and forth, but there are tools that can help you with this task, such as AutoMapper.