Ajay
Ajay

Reputation: 317

My ASP.NET MVC project loads slower

Hi I have project developed in ASP.NET MVC. I am using Entity framework database first approach. Problem I am facing now is, first time when user loads my website, it takes time to load which is unusual. So I am searching for the reason behind this. Can anyone help me in this?

For a moment, I am assuming since I am using database first approach, I have to load all database to my project first before i connect. So I think it is making my website to load slower.

If this is the case, can someone guide me to generate connection string dynamically during run time in entity framework and connect to database?

I have stored procedure from which I can get connection string. But I dont know how can i use that connection string and connect to database.

Upvotes: 0

Views: 479

Answers (1)

Chintana Meegamarachchi
Chintana Meegamarachchi

Reputation: 1820

When you say first time when user loads my website, it takes time to load which is unusual” could you give us a comparison of how slow is slow the first time. And by “first time” is you mean after re-starting IIS or re-starting the app-pool, it may take some time as some of your code would have to be turned into native code by the just-in-time computer.

EF may slow you down if you have many hundreds of tables and it has to re-construct the context based on all of those tables and relationships. Even if it is the case, you would see the delay in every time you create a new EF context. But if this is the case, you may have to create multiple contexts each with a limited number of tables to manage. A good read on that http://msdn.microsoft.com/en-us/magazine/jj883952.aspx

Other than that, I would suggest you do the usual things such as pre compile your views (http://geekswithblogs.net/Aligned/archive/2013/05/28/pre-compiling-your-mvc-views.aspx) and use caching Love to hear how it went

Upvotes: 1

Related Questions