4

I'm developing an ASP.NET Web Forms application under Visual Studio 2012. I'm using Web Deploy and Publish Web dialog for application deploy. I'm trying to deploy a database schema using the Update database feature. I entered a connection string pointing to remote SQL Server. If I click the "Test connection" button Visual Studio says test connection is succeeded.

enter image description here

Then I go to Preview tab and click the Preview database link.

enter image description here

And in the opened window I have the message

Web deployment task failed. (Could not generate deployment script. Unable to connect to target server. Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_EXECUTING_METHOD.)

Other project files are deployed normally. I'm able to connect to SQL Server using SQL Server Management Service. But why the database could not be updated? I tried to disable server firewall - with no luck.

  • Visual Studio Professional 2012
  • SQL Server 2012
  • Web Deploy 3.0

Update

All works fine if I use SQL Server Authentication with the sa login instead of Windows Authentication in connection string for DatabaseEntitiesRaw. But Windows Authentication works fine for SSMS, and I want to use it since I'm deploying only from computers within my company's domain. Is it true that dbDacFx doesn't work with Windows Authentication?

alastairtree
  • 3,960
  • 32
  • 49
Mikhail
  • 20,685
  • 7
  • 70
  • 146
  • What happens if you just deploy instead of preview? – Andrew Clear Aug 30 '12 at 16:57
  • @aclear16 The same error in the output window: 2>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\Web\Microsoft.Web.Publishing.targets(4377,5): Error ERROR_EXECUTING_METHOD: Web deployment task failed. (Could not deploy package. Unable to connect to target server... – Mikhail Aug 30 '12 at 17:00
  • You probably need to enable EF Code first migration. Use the link next the triangle with the exclamation point in it. – Andrew Clear Aug 30 '12 at 17:06
  • @aclear16 I'm trying to deploy this database as a stand-alone one, without any connection to the EF, since I'm using a Data First approach. – Mikhail Aug 30 '12 at 17:17
  • Hmm that's strange. Can you email me so that I can work more closely with you to solve this? My email is sayedha[at]{MicrosoftDOTcom} – Sayed Ibrahim Hashimi Aug 30 '12 at 22:45
  • 1
    Problem was in the authentication method. See the update section in the initial question. – Mikhail Aug 31 '12 at 13:34
  • You cannot use Windows Auth because this is flowing through MSDeploy and the Web Management Service. – Sayed Ibrahim Hashimi Mar 14 '13 at 07:44

1 Answers1

3

Deploy script runs from AUTHORITY\LOCAL SERVICE user, so you have to add this user to SQL server. Do not foget to add db_owner role for the user.

Raiden
  • 31
  • 2