Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Optimizing Entity Framework

Entity Framework is fine but some queries are sub-optimal. Can one write some SQL queries by hand or as MS SQL Server 2008 R2 views, execute this selects and then associate somehow entities with them? I examined some generated SQL and they are quite ugly...

Question 2: Is MS SQL Server 2008 R2 caching queries? I'd like to have strong caching, how can I tune it? (with MySQL it's so simple).

like image 281
Cartesius00 Avatar asked Jun 26 '11 18:06

Cartesius00


1 Answers

You have a lot of options available to you. You can use .ExecuteStoreCommand() in EF 4.1 to execute SQL against the database, or you can map stored procedures into EF as well. Furthermore, you can map views as entities in EF if that's necessary.

SQL Server has very sophisticated caching mechanisms for data pages as well as execution plans , and it's pretty much automatic to the developer. I would suggest posting a question with concrete example with the operations you want to optimize.

like image 152
Dave Markle Avatar answered Oct 25 '22 04:10

Dave Markle