For an ASP.Net MVC 3 website, which will be a big website( 6Month/men for the FIRST version). I’m searching what is the right approach to use the power of asp.net MVC and the power of EF.
The “power” I hope I could use of EF:
- POCO generation
- LINQ Queries to interrogate the database
- The navigation between objects parents <-> children
- The lazy loading
The “power” I hope I could use with MVC(regarding data):
- Data validation
- ?? The usage of EF object as Strong type for my view?
But I’ve several concern:
- The “recursive” serialization which will happen if I serialize my EF (with bi-directionnal links)for JSON, how to avoid this?
- I cannot put validation attribute on POCO class
So, I know that my question is a little “generic”, but I can’t find a good link which point me to a direction to solve all problems which comes with the combination of those two tech, do you know a website or do you have already got those kind of problems?
No this is not a power. In most cases this is just an issue which raises both your main concerns. Use specialized model views for your views and Json handling actions and you will be fine. If you worry about conversions between model views and entities check for example AutoMapper to simplify this.
Btw. lazy loading in web application can be issue as well. You almost always know what data you need to handle current request so load them directly instead of using lazy loading.