asp.net mvc with entity framework database first domain model validations -
i'm developing asp.net mvc web application project, , i'm using entity framework database first approach, make validations on generated model classes, know if make validations on them directly, model validations overwritten every time domain models regenerated.
so made research, , found 2 approaches use scenario:
1- using buddy classes (how add validation poco(template) classes).
2- using viewmodels , auto-mapping them entities (designing mvc repository using viewmodels
i see sort of redundant code in these 2 methods, so, question is:
which 1 of 2 approaches best flow?
1) correct solution adding validation metadata entity framework objects. validation triggered automatically ef before calling savechanges()
2) aproach creating data transfer objects
ef objects. when want return objects client (like in json format) - , don't want expose ef specific properties (like navigation properties, primary keys etc)
Comments
Post a Comment