Visual Studio web deploy of ASP MVC app

229 views Asked by At

I'm trying to web deploy a code first ASP MVC app. The shared host has web deploy enabled, and the app uploads and gets published. However, it can't create the database.

[Win32Exception (0x80004005): The system cannot find the file specified]

[SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 52 - Unable to locate a Local Database Runtime installation. Verify that SQL Server Express is properly installed and that the Local Database Runtime feature is enabled.)]

Is there something on my end I need to do? Would it be better to switch to database first?

My publish profile is:

<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <WebPublishMethod>MSDeploy</WebPublishMethod>
    <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
    <LastUsedPlatform>Any CPU</LastUsedPlatform>
    <SiteUrlToLaunchAfterPublish>http://abalter-001-site1.myasp.net/</SiteUrlToLaunchAfterPublish>
    <LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
    <ExcludeApp_Data>False</ExcludeApp_Data>
    <MSDeployServiceURL>https://abalter-001-site1.myasp.net:8172/MsDeploy.axd</MSDeployServiceURL>
    <DeployIisAppPath>abalter-001-site1</DeployIisAppPath>
    <RemoteSitePhysicalPath />
    <SkipExtraFilesOnServer>True</SkipExtraFilesOnServer>
    <MSDeployPublishMethod>WMSVC</MSDeployPublishMethod>
    <EnableMSDeployBackup>True</EnableMSDeployBackup>
    <UserName>ifc\abalter-001</UserName>
    <_SavePWD>True</_SavePWD>
    <PublishDatabaseSettings>
      <Objects xmlns="">
        <ObjectGroup Name="GatorsContext" Order="1" Enabled="False">
          <Destination Path="" />
          <Object Type="DbCodeFirst">
            <Source Path="DBContext" DbContext="Gators3.Models.GatorsContext, Gators3" Origin="Configuration" />
          </Object>
        </ObjectGroup>
        <ObjectGroup Name="DefaultConnection" Order="2" Enabled="False">
          <Destination Path="" />
          <Object Type="DbCodeFirst">
            <Source Path="DBContext" DbContext="Gators3.Models.ApplicationDbContext, Gators3" Origin="Configuration" />
          </Object>
        </ObjectGroup>
      </Objects>
    </PublishDatabaseSettings>
  </PropertyGroup>
  <ItemGroup>
    <MSDeployParameterValue Include="$(DeployParameterPrefix)DefaultConnection-Web.config Connection String" />
    <MSDeployParameterValue Include="$(DeployParameterPrefix)GatorsContext-Web.config Connection String" />
  </ItemGroup>
</Project>
1

There are 1 answers

5
Dacker On

I haven't used this way of deployment before. I prefer publishing to a local directory and use that to deploy to all locations, so all binaries are exactly the same and for each environment. Settings are managed outside of deployment, to configure different settings per environment.

But in your case I bet there are still two connection strings in the Web.config of your web application on the server. Check those to see whether:

  1. the server name is correct.
  2. the database name is correct.
  3. check whether there's access to both the server as the database for the account required. Usually this is the account the application pool is running with