There are a few things you need to know before trying to debug Appplication_Start . There is -
One: when the code is executed and why it cannot be debugged by attaching to it.
The application launch method starts when you start the application pool and launch your website for the first time. If you deploy new results to IIS, IIS can restart it yourself, but there is no guarantee that it will. Thus, the deployment of new codes does not guarantee a restart of the pool and the launch of the application. You must restart the application pool to ensure that the application starts.
When debugging applications, IIS Visual Studio joins a process with the name w3wp.exe or similart (I forgot the actual name of the executable file), which is a workflow and is available only after, remember that your application pool is up and running. Thus, in other words, if you see this in the list of services, then the application has already been launched and joining it will not allow you to debug it. This is a kind of tug of war over time.
Thus, in other words, you can delay the launch of the application if you are not very fast.
Two, solution 1 - with Dev Server
Run the application in the visual studio with the Asp.net or IIS express development server, after which you can debug. But if you really want to debug IIS, check the next section
Two, solution 2 - with IIS
There is a library called System.Diagnostics , Debugger , and it has a good way to call a debugger in code. You can read it here - http://msdn.microsoft.com/en-us/library/system.diagnostics.debugger.break(v=vs.110).aspx
Change the application to start with this -
public void Application_Start(){ .......
When this line is executed, IIS will stop execution and show you the debugger selector window (similar to attached)
, keep your solution open in vs and select it from the list, you can debug as usual ... :)
If you are using Windows 8 and the debugger does not start, read this article to enable it -
http://blogs.msdn.com/b/mapo/archive/2013/11/07/debugger-launch-not-displaying-jit-debugger-selection-popup-on-windows-8-8-1.aspx
Three: a very important thing
I noticed that you said that you are adding db entries to Application_Start. You should keep in mind that Application_Start does not have an HttpContext , ViewContext , so your Db access code can be unsuccessful for many other reasons.