I'm new to Entity Framework, and currently developing an MVC 5 application with Code-First Entity Framework 6.1.2.I need to write custom reports. Instead of writing complex linq, I can write a couple quick Stored Proc's and write the results to CSV. Can I call these procs with EF? or would I just be better off using ADO.NET?I know I can do: var data = db.Database.SqlQuery<ReportDetailed>(sp_rpt_report @reportType @endDate, @startDate, parameters).ToList<ReportDetailed>();But I would need to build a rather large model for each report result, and that seems like a lot of work for little reward and wrong.
Entity Framework 6 and Stored Procedures
asp.net;entity framework;stored procedures;asp.net mvc5
I think Robert Harvey's comment is very good advice. In the long-run, I think you'll wish you did it in Linq. Here's why:Changes in Entity Framework for your data objects will be easier to make changes to the report data sets. The stored procedures will probably just fail. You'll need to maintain them separately. There will be no shared logic that can be reused.You'll learn Linq much better.I do think you can take a few steps to accomplish this. It sounds like you're better at this in sql and you may have some pressure to get this done. So go ahead and create a stored procedure that works. You'll understand the requirements better. Then you can get to work on refactoring it in linq. You'll have a result set from the stored procedure that you can use to test/compare your Linq results. You'll feel more comfortable knowing you've been able to accomplish the same thing in the new language. This way you can get your app into production in parallel with becoming a better Linq programmer. The next programmer that has to maintain this app will appreciate it. And don't forget, that new programmer could be you in a year or so.