We have a 3-tier architecture: Web, Business, Models using the MVC pattern. Models are Code-First using EF6. Currently we access the dbContext directly in our Controllers to query and save changes. We define all the relationship constraints on the Models. However, we have many additional constraints on the models that are spread about in the controllers, or the Business layer as part of other processing.
Is there a cleaner way of accomplishing this whereby all the business constraints on the Models can be enforced? We have used the repository layer in the past on other projects, but it becomes inflexible and tedious to go through it for everything. Is there a best of both worlds approach whereby we can use the dbContext directly to query things, but when saving to db, we can be ensured that all the business constraints will be enforced with any violations passed back through to the caller?
Edit: this explains succintly why I don't want to use Repository pattern again.