title: Could not connect to database on ASP.NET Web Site Administration Tool
body: <p>What's the right process to use ASP.NET Web Site Administration Tool? I want to use this tool to configure roles and membership.</p>
  
  <p>Steps that I tried:</p>
  
  <ol>
  <li>Create MVC web application.</li>
  <li>Run aspnet_regsql to create related database. The command tool is suggested by error messaage below. Although I realize the Role, Membership table has been created since project creation.</li>
  <li><p>Modify web.config of new webapplication:</p>
  
  <pre><code>&lt;system.web&gt;
  &lt;roleManager enabled="true" defaultProvider="simple"&gt;
  &lt;providers&gt;
      &lt;clear/&gt;
      &lt;add name="simple" type="WebMatrix.WebData.SimpleRoleProvider, WebMatrix.WebData"/&gt;
  &lt;/providers&gt;
  &lt;/roleManager&gt;
  
  &lt;membership defaultProvider="simple"&gt;
  &lt;providers&gt;
  &lt;clear/&gt;
  &lt;add name="simple" type="WebMatrix.WebData.SimpleMembershipProvider,WebMatrix.WebData"/&gt;
  &lt;/providers&gt;
  &lt;/membership&gt;
  ...
  ...
  &lt;add name="DefaultConnection" connectionString="Data Source=(localdb)\.\IIS_DB;InitialCatalog=aspnet-DemoWebApplication-20130625124639;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnet-DemoWebApplication-20130625124639.mdf" providerName="System.Data.SqlClient" /&gt;
  </code></pre></li>
  </ol>
  
  <p>Error message seen on the tool page:
  There is a problem with your selected data store. This can be caused by an invalid server name or credentials, or by insufficient permission. It can also be caused by the role manager feature not being enabled. Click the button below to be redirected to a page where you can choose a new data store.</p>
  
  <p>The following message may help in diagnosing the problem: You must call the "WebSecurity.InitializeDatabaseConnection" method before you call any other method of the "WebSecurity" class. This call should be placed in an _AppStart.cshtml file in the root of your site.</p>
  
  <p>Can you help? Please let me know if you need more information.</p>
  
  <p>I've investigate this issue for hours, found below helpful threads, but still does not fix it completely:</p>
  
  <ol>
  <li><a href="https://stackoverflow.com/questions/3650334/web-site-administration-tool-errors">Web Site Administration Tool ERRORS</a></li>
  <li><a href="https://stackoverflow.com/questions/720481/web-site-administration-tool-not-working-with-asp-net-mvc">Web Site Administration Tool Not Working with ASP.NET MVC</a></li>
  </ol>