0

I'm using ASP.NET Web API with EF 6 (Code First) and for development purpose I created an initializer with a DropCreateDatabaseAlways.

I deploy the application on a remote server (IIS 8.0) and I noticed that after some inactivity, when a call is made on the API, the initializer is called. I thought this initializer only drops and creates the database on each run of the application, but once deployed the application doesn't stop to run, so is there any timeout, or something like this ?

If you have any ideas why is it happening.

Here is some code and logs to help. The Context :

public MyDAL()
        : base("MyEntities")
    {
        Database.SetInitializer<MyDAL>(new MyInitializer());
        this.Database.Log = s => log.Info(s);
    }

Some logs :

// At 05:30 the request is successful without droping/creating the database 2014-12-28 05:30:38,312 INFO - -- Executing at 28/12/2014 05:30:38 +01:00

2014-12-28 05:30:38,343 INFO - -- Completed in 27 ms with result: SqlDataReader

2014-12-28 05:30:38,343 INFO -

2014-12-28 05:30:38,343 INFO - Closed connection at 28/12/2014 05:30:38 +01:00

// At 06:46 A client asks for the Authentication Service 2014-12-28 06:46:15,398 INFO - 2014-12-28 06:46:21,070 INFO - Opened connection at 28/12/2014 06:46:21 +01:00

2014-12-28 06:46:21,132 INFO - Started transaction at 28/12/2014 06:46:21 +01:00

2014-12-28 06:46:21,132 INFO - CREATE TABLE [dbo]...

boluo
  • 61
  • 6
  • Maybe this http://romiller.com/2014/06/10/reducing-code-first-database-chatter/ – ErikEJ Dec 28 '14 at 11:02
  • Are you managing the IIS application or are you running on a shared service? IIS application pools come with recycle settings default to 29 hours (depending on what version you use). This is to avoid webapps with terrible memory leaks to let the server to be unstable. – rodrigogq Dec 28 '14 at 11:21
  • @rodrigogq I'm managing the IIS application. I increased in my application pool the Idle time-out (was at 20minutes before) and for now it seems to work. I'm just waiting for more tests if the Idle time-out was the issue. – boluo Dec 28 '14 at 11:44

1 Answers1

0

So, it seems to be that, the problem was the configuration of the application pool in IIS. The Idle time-out was set before at 20 minutes and now with the timeout set at 24h, the problem disappeared.

boluo
  • 61
  • 6