0

I have dome some seriously complex projects using the traditional WebForms and Stored procedures. Recently, however, I did a project using MVC and Entity Framework and I liked they way it works with Entity framework. They way its lets you deal with entities in object oriented manner...Its awesome. The project was not very complex. Just about 12 -15 tables.

We all know that WebForms and stored procedures are more mature and hence reliable technologies of doing thing. With my knowledge EF is still evolving. It doesn't even have the very basic "Unique Constraints". Although there are work around for things, It make's me think twice before starting a project with EF.

What I want to ask is, If I want to start another huge and complex project, can I chose to go with MVC & EF ? Is there any risk of hitting a dead end ?

Bilal Fazlani
  • 6,727
  • 9
  • 44
  • 90
  • 1
    I'd take EF over Stored Procedures for my primary mode data access anyway. If you're concerned about the design of your database, you can go with the database-first approach, and not use EF to the database schema for you. – Matthew Mar 03 '13 at 05:58
  • Agrree with @Matthew; I suppose it's a matter of preference, but I'm old school.. I never trust my db design to be code generated.. I design the db first and then create my entity classes after. And for some features (like unique constraints).. it has to be done on the DB anyway.. EF does not yet support generating that (as I mentioned in my answer below) – Matt Mar 03 '13 at 06:03

2 Answers2

2

Personally I use EF and MVC for every one of my new projects. I have yet to encounter a drawback. On the contrary, I find MVC far better to work with. With regards to your stored procedures, they are still and always will be more efficient than running TSQL ad-hoc.. just replace your normal ADO.NET code with EF and continue using the stored procedures. As for unique constrains, you still do those in the DB itself. More info here:

Unique constraint in Entity Framework

and here:

Does Entity Framework 5 support unique constraints?

Also, check this link for using stored procs and ad-hoc TSQL queries with EF: http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/advanced-entity-framework-scenarios-for-an-mvc-web-application

Community
  • 1
  • 1
Matt
  • 6,787
  • 11
  • 65
  • 112
  • 1
    "[...stored procedures..] are still and always will be more efficient than running TSQL ad-hoc" This is not true, please see this answer: http://stackoverflow.com/a/12948506/115049 – rossipedia Mar 03 '13 at 06:04
  • @BryanJ.Ross; very interesting. That goes against everything I've been told for years. Thank you for this. – Matt Mar 03 '13 at 06:07
  • It depends on what metric you're using for efficiency, if you're talking about developer performance, I find using EF or ad-hoc SQL statements to be easier (and faster) to write and manage. Of course, every company has their own set of needs. – Matthew Mar 03 '13 at 06:09
  • So basically, I would assume the answer as I can use EF and if there is any roadblock, I will be able to use stored procedures with EF. right ? – Bilal Fazlani Mar 03 '13 at 06:17
  • Yes, you can mix and match however you want. There's nothing stopping you from using EF and stored procedures together. – Matt Mar 03 '13 at 06:23
  • See my edit above for using stored procs with EF. I think you will find that interesting – Matt Mar 03 '13 at 06:26
1

There is little risk of using EF and MVC for complex projects. If you use EF, you can still call stored procedures or execute dynamic sql queries (not that you should). EF gives you options. There maybe more risk of not using it. Don't forget SO is built with MVC.

Ray Cheng
  • 12,230
  • 14
  • 74
  • 137