Update database feature not working in Publish Web dialog in Visual Studio 2012 - asp.net

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.
Then I go to Preview tab and click the Preview database link.
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?

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.

Related

Deploy existing data on ASP.NET web project from local database in Visual Studio to Azure database

I've successfully deployed my ASP.NET project to Azure but the database has been deployed with no data, consequently throwing internal server errors due to functionality requiring that data. I can't see the exact error message as I'm unable to disable customErrors on my project (there's no webconfig file on Razor Pages)
I need to update my database on Azure with the data currently stored locally. How do you do this and is this possible?
N.B - I am using EF core with code-first migrations for data access
On the local machine open the "Microsoft server SQL management studio", connect to the local database server and navigate to the appropriate database. Rightclick on the database name and select "Generate scripts...". Select the tables you want to export, then click "next>". On this screen click the "Advanced" button, scroll down to "Types of data to script" and select "Data only". Now you can generate the script and copy that to a connection to the Azure DB, that can be an other query in de Management Studio or in the Azure portal.

Hosting an asp.net website in my computer

I have an app I am modifying for a client. The app is in asp.net. I have read that I can deploy the app in three ways:
xCopy Deployment
Precompiled Deployment
Web Setup Project
I would like to go with xCopy method. I have not installed visual studio but have SQL server installed.
Coming from a PHP background, is IIS just like apache where I can copy my files inside a directory in IIS and launch the app in a web browser or is there an extra step that required to be able to run the asp.net web app?
Here is a complete guide to:
Install IIS in windows
Install SQL Server Express
Publish to IIS in Visual Studio
Finally, test in the test environment
Note: There is no need to install IIS, just enable its some settings. And you have to install SQL Server and Visual Studio.
Edit:
Install IIS
Open Control Panel, Programs and Features, Turn Windows features on or off.
Make sure that ASP.NET 4.5 is selected under Internet Information Services -> World Wide Web Services -> Application Development Features.
Set ASP.Net Framework from v2.0 to v4.0: Press Windows + R and type "inetmgr" hit enter.
In the Application Pools pane under connections, click DefaultAppPool, and then in the Actions pane click Basic Settings.
In the Edit Application Pool dialog box, change .NET Framework version to .NET Framework v4.0.30319 and click OK.
Install SQL Server Express
Download it from here either x64 and x86 based.
After downloading SQL Server run the setup and click New SQL Server stand-alone installation. In the installation wizard accept the default settings.
Publish to IIS in Visual Studio
Run Visual Studio as Administrator by Right - Click on VS icon.
Right - Click on your project select Publish, in Publish Web create new Profile.
In Connection tab enter localhost -> Service URL, Default Web Site/yourProjectName -> Site/application, http://localhost/yourProjectName -> Destination URL
In Settings tab check Exclude files from the App_Data folder.
enter Remote connection string that you have use to connect with SQL Server database.
Check Update database and click Configure database updates add sql script Grant.sql that you will run in SQL Server which is like:
IF NOT EXISTS (SELECT name FROM sys.server_principals WHERE name = 'IIS APPPOOL\DefaultAppPool')
BEGIN
CREATE LOGIN [IIS APPPOOL\DefaultAppPool]
FROM WINDOWS WITH DEFAULT_DATABASE=[master],
DEFAULT_LANGUAGE=[us_english]
END
GO
CREATE USER [ContosoUniversityUser]
FOR LOGIN [IIS APPPOOL\DefaultAppPool]
GO
EXEC sp_addrolemember 'db_owner', 'yourProjectName'
GO
Finally click on Publish.
Test in Environment
Check that your project files have exits in wwwroot folder at C:\inetpub\wwwroot\yourProjectName. Run your project index.aspx file and test it.

How do I stop visual studio 2015 for web iis service

When launching my MVC app built using this tutorial, it uses IIS Express as server. When I want to go back to edit my application the IIS Express server doesn't stop the page, so next time I launch my MVC app it has not changed.
I can not stop the service using the IIS Express manager or windows service manager because Visual Studio Express 2015 for Web is the service owner.
Under my project properties, I can find settings for Servers under the Web tab, but nothing useful. Where / how can I make Visual Studio stop the service when I stop debugging my project?
I solved the issue by opening my project properties Web tab and clicking on the button Create Virtual Directory. Now I can stop the IIS Express service using IIS Express manager from the status bar.

CREATE DATABASE permission denied in database 'master' - using Web Deploy, EF Code First, Visual Studio

Visual Studio 2012 Express, EF5, Code First Migrations, Web Publish.
I am doing a web publish from a Windows 8 Laptop to a Windows Server 2008 R2 web server using Web Deploy from Visual Studio 2012.
The files are uploaded fine. But I get this error:
CREATE DATABASE permission denied in database 'master'
When Code first tries to create the database.
The Web Publishing wizard uses a windows user to login - that user has db_owner permissions on the master database.
Exactly what do I need to do to grant CREATE DATABASE permissions? (or see which user tried to do it - the error doesn't report that for some reason?!).
Thanks.
I've just come across this problem and I resolved it following the instructions here. Effectively, the "IIS APPPool\DefaultAppPool" user must first be added. While adding it, ensure that
as its "Server Roles" it is a "sysadmin".
If you'r running the application from IIS, then IIS APPPOOL\{Your apppool name} is the sql user trying to create the db. If there is no such user in you sql server then create one with the name IIS APPPOOL\{Your apppool name} and give server role dbcreator, public and sysadmin. Now I hope you won't see the error, code first should create the db.

Publish ASP.NET website + database to Windows Azure Websites

I've signed up for a test account on Windows Azure to test it out. I build a Hello world ASP.NET web application + database just for testing.
I installed Visual Studio 2012 RC and installed the Windows Azure software.
In Windows Azure I've created a new Website e+ Database, I think that is running fine (http://azuretest.azurewebsites.net)
I downloaded the Publish profile from Windows Azure and import it in Visual Studio. When I publish the website I select to publish the database, select the right connection string (from the publish profile).
After publishing I get this error:
Error 1 Web deployment task failed. (Could not complete an operation
with the specified provider ("dbSqlPackage") when connecting using the
Web Management Service. This can occur if the server administrator has
not authorized the user for this operation. dbSqlPackage
http://go.microsoft.com/fwlink/?LinkId=178034 Learn more at:
http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_USER_NOT_AUTHORIZED_FOR_DEPLOYMENTPROVIDER.) 0 0 azuretest
The url's in this error message links to articles from 2008 and 2010. I don't think that I can find any good info there..
The error says
This can occur if the server administrator has not authorized the user
for this operation
but I don't think I can authorize anything on a shared Windows Azure Website, can I?
I just answered this at http://social.msdn.microsoft.com/Forums/en-US/windowsazurewebsitespreview/thread/3f99e1e3-e030-47e0-9e43-f029663ca806.
Hi Marcel, I work on the Visual Studio Web team. When we released VS 2012 RC we had the hopes that we would be able to finalize the server side components of the Update Database checkbox by the time that the RC went out. Unfortunately we were not able to do that, so the Update Database checkbox in VS 2012 RC only works if you are publshing to localhost.
We are working to get the server side pieces ready but we cannot commit to a schedule yet. I've blogged about this at http://blogs.msdn.com/b/webdevtools/archive/2012/06/14/vs-publish-dialog-update-database-dialog-disabled.aspx.

Resources