How Visual Studio 2015 Publish Web app and SQL, update DB - sql-server

starting using VS2015 and publishing to azure websites. I'm developing using a local DB for faster interaction. And I'm publishing Web Application and a SQL Database (Project > publish). But I always getting this error.
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web\Microsoft.Web.Publishing.targets(4276,5): Error ERROR_SQL_EXECUTION_FAILURE:
"CREATE TABLE [dbo].[__MigrationHistory](" There is already an object named '__MigrationHistory' in the database" #ERROR_SQL_EXECUTION_FAILURE.)
Publish failed to deploy.
And it is the same for every table on DB.
How can I somehow just update the tables on the server?
There is another way to work with apps and DB in local machine and later update to the server?
I'm using vs2015, webDeploy 3.6, Windows Azure web app and SQL DB.

I got this solved by removing all files from Properties\PublishProfiles. There was lots of old files from my first publishing attempts. After this I created new profile.

Related

How do visual studio 2013 data compare tool for Windows Azure?

Related : Visual Studio 2013 (Professional Edition)
I am trying to create Data Migration Script to deploy the changes on Staging Server.
This works locally fine. But When I try to run the generated Script on Azure Database, I get TextPtr is not supported on Azure platform. I studied more about it & found that the newer editions of SQL Server (sply for Windows Azure (SQL 2014 may be)) has dropped some keywords/functionalities the list can be found here.
The Sql Database Project only provides the Schema Compare, but Data Compare is avilables in tools Section (where we can not set Target Project Type property).
I wonder how can I deploy/Migrate the changes made in one environment to another in such a Situation. Currently I had to overwrite the existing Database on Azure platform.
But this is not Identical also, for first time this could work but not for later, as there could be some changes made to the Staging or other environments.
I had a similar problem, when trying to migrate between a test and staging environment in Azure. As a quick fix, I got around the problem by just doing a "copy" of the dev database via the Azure dashboard.

Cannot deploy VS 2010 database solution to database if the deployed database was manually deleted

I am working on creating a visual studio database solution so that i could deploy databases in a more managed manner. Following are the steps that i performed after adding some sample tables and SPs in the solution.
Deploy the database to my local machine (and a new database is created).
Add some mock data to the tables in SSMS.
Add couple of columns to one of the tables in the VS 2010 solution.
Build the solution and deploy the database again (this time it deploys only the changes made to the schema).
Verfiy that the existing data was intact and new columns have been added to the table schema.
Everything is working as expected till this point.
Now I delete the database manually which was created by the deployment.
Go to VS 2010 and deploy the solution (expecting that it should do a clean deployment of the database), however i get the following error :
------ Deploy started: Project: MyDatabase, Configuration: Debug Any CPU ------
Pre-Deploy: Starting script execution…
Pre-Deploy: Finished script execution.
MyDatabase.dacpac(0,0): Error :
-->Cannot upgrade the DAC for database MyDatabase, a database with that name does not exist. Specify a valid database name.
Is there any setting in my solution where i could specify that the deployment should do a clean install if the database does not exist?
Or
Do i need to write separate (database creation) scripts if the database does not exist?
I ran into this issue as well. I deleted the database and could not deploy again. Then I found this link. DAC application needs to be deleted in the SQL Server Management Studio.
http://msdn.microsoft.com/en-us/library/ee240822.aspx
To Delete a DAC application
In SQL Server Management Studio connect to the database
Expand the Management node.
Expand the Data-tier Applications node.
Right-click the DAC to be deleted, and then select Delete Data-tier Application…
Complete the wizard dialogs:
I deleted the application and was able to deploy again. I am still learning that DAC is application.

Visual Studio Database Project + Deploy + TFS Build + Multi Tenancy

We have recently migrated to using the Visual Studio database projects. What we want to do is for the database to deploy when the TFS build server builds.
This is relatively simple and we have this working for a single database, however, what we need is for it to deploy to multiple database as we have a SaaS product with multiple databases. So for example, when we do a QA build, all the different databases with various configurations on the QA DB server should be updated.
Is there a 'proper' way to do this?
Our current plan is to take the deployment .sql script that will be generated from the database configured for deployment, then create a custom build task which runs this script against the rest of the databases.
I don't think there is a standard way of doing this, so we created a custom build task that iterates over the databases we want to deploy to executing the deployment script generated by the standard database project's deploy against each DB.

Browsing an Entity Framework code-first database + Azure Dev Fabric

I have a database created using the code-first approach against SQL Server Express. I'm trying to view the database in Management Studio, but cannot find the database. VS Database Explorer also cannot seem to find it.
I've searched about but cannot find any reference to what I'm after. Is it possible to browse a database running in the dev fabric?
Usually if we create a new database in Visual Studio, it will give us a database file, but it won’t register the database in SQL Server Management Studio. So please manually attach the database file to SQL Server Management Studio. First please find the database file, normally it is under the AppData folder of our project. Then I would like to suggest you to check http://msdn.microsoft.com/en-us/library/ms190209.aspx for instructions on how to attach the database.
Best Regards,
Ming Xu.
Take a look at Scott Gu's blog post on EF Code First and DB Generation: http://weblogs.asp.net/scottgu/archive/2010/07/16/code-first-development-with-entity-framework-4.aspx
The Azure Dev Fabric has nothing to do with the DB layer, the connection string handles all this for you i.e. when you deploy to SQL Azure your DB will go there, the only thing that needs changed is the connection string...from localhost (Dev Machine) to SQL Azure connectionn string
HTH

How to set up Database for ASP.NET MVC Application

I created an data driven ASP.NET MVC Application locally and it works fine. Within my App_Data Folder of my project i see two databases: ASPNETDB.mdf and myProjectDatabase.mdf.
I uploaded my project files an the webserver, so that I can actually open the website. But I couldn't figure out how to connect my Database that I created locally to that website. My Website uses Authentication so that it is necessary that a user logs in/registers. But because the database is not connected this obviously doesn't work, because the application needs a database to save and retrieve user information.
I'm using Visual Studio 2010 Express and downloaded Microsoft SQL Server Management Studio as well to work with my database. With Microsoft SQL Server Management Studio I already connected to my database with the login information my provider gave me. But how can I import my local databases? Do I need to import ASPNETDB.mdf as well, because that is where the user information are stored?
I would be very thankful for help
What version of SQL Server do you have on your production server? SQL Server Express can attach to those local MDF files. If you're using SQL Server Standard, you'll need to attach them to the SQL Process.
Also, the ASPNETDB.MDB file is the authentication database that is automatically created in your MVC project. That is the DB that stores usernames and passwords, so yes, you will need to move that database over as well.

Resources