.NET SQL Azure Migrations - asp.net

I've finally managed to get my database to Azure! transformed my connection strings and it all logs in successfully after 3 weeks of trying.
Though just testing everything now and made a small change to my local model, ran a local migration and published again however when trying to access the Azure database it says I need to run a migration as the application DB context has changed.
How do I run migration on Azure?

Locally change the connection string to point to Azure Database (you will need to log into Azure Portal => SQL database => Select the database => Set Server Firewall => Add Client IP) and run update-database.
The correct approach would be enabling automatic database migrations.

That depends on how you publish the application, the version of Visual Studio and the development environment, eg. MVC 5 or Core. You can use the built in migration support from Visual Studio Publish, or set your default database to the Azure connection string and run Update-database from the Package Manager console again.
Look at the section on Database Migration here

Related

Web App and Database Host on Azure

Hy Guys,
I'm new to Asp.net and Azure. I was working on ASP.NET with the help of this documentation link, When I publish my project on Azure by creating the Web App with latest portal on Azure, but it is only my application host on the Azure. And now i need to publish the my project database to Azure. In the present portal, the database option is not present there when we create the Web App on Azure to host the database as well with the Web project. But in the old portal as the documentation link guides us the database option is also present there when we publish our Web project on Azure.
Can anyone explain me how can i deploy my Web App existing database to Azure even if my Project has been deployed on Azure?
How can I deploy my existing Web App Database to Azure on the new portal.
If you use Code First Model of Entity Framework, you could just configure the connection string for your web application when you publish your web application. Entity Framework will generate tables for you automatically.
If there are existing data in your database which you want to migrate to Azure SQL Database. You could download a tool named Migration Assistant which will help you do it. For detail steps, link below is for your reference.
SQL Server database migration to SQL Database in the cloud
In the documentation he is using the old dashboard of Azure in which database option is attached with the Web App Publish procedure.
A small difference between old dashboard and new dashboard is that the creating Azure SQL Database feature is hidden when you create your app service. You need to click Explorer additional Azure services link to open the a new window for creating Azure SQL Database.
After creating a database, you could choose the database in the Setting tab when you publish your web application.
You also could create a database directly in Azure portal. After creating a database, you could get the connection string from the overview page.
If you make changes to a database schema and are using code first EF, will EF update your database schema when you redeploy your web app?
It depends whether you have enabled and run the migration. In the publish setting window, we could click the [Execute Code First Migrations] button to update the database schema .
If this button is disabled in the setting window, we need to run Enable-Migrations command in Package Manager Console.
In Visual Studio click menu Tool -> NuGet Package Manager -> Package Manager Console, input Enable-Migrations and run it.

Deploying ASP.NET Core solution with class library to Azure

I'm working in VS2015 and have a ASP.NET Core solution with two projects - an API Web Project and a Class Library that holds all the data entities, context and Entity Framework migrations. The API project references the class library and all works well on my local machine.
I now want to deploy the solution to Azure and this is where I'm hitting the problem. If I right click on the API project and go through the Azure App Service publish wizard, on the Settings tab I expand Databases and the message is "No databases found for this project" - which I'm guessing is because it can't find a context as it's not in this project.
If I do the same on the CL project though, there is no Azure App Service deployment option, the only option is File System and clearly there's no option to create the database there either.
So, in summary, my question is how I can deploy this type of solution to Azure and have the database created and migrations applied?
I think you need to create the DB first in the azure and then try to publish your application through the wizard. The database is on your local machine and the application will work just fine on your local environment. But on the cloud you have to first create the database on Azure SQL. Then you need to get the SQL connection string from the portal and update your config file accordingly. Once this is done you can then publish your application from Visual Studio. Please note that the wizard will still not show you the databases, but the application, when configured properly will run fine.

Problems deploying app and database to Azure

I have built an asp.net webforms app with a DB which works great locally. I created a new context with an initializer class as they describe here. The DB is nicely seeded with my initial data onto localDB and everything runs beautifully. (Doing code first, no migrations according to the tutorial in the link above).
I have published my app to its online counterpart and everything seems fine until I enter a page which I know contains a context of my DB. At this point the database should be seeded as it successfully does locally however I just receive a time-out error. I suppose it is not connecting to my DB properly.
What is the proper method of publishing a webforms app and DB together to Azure?
Assume you are using Azure App Service (formerly known as Azure Website).
LocalDB is not supported see Using a LocalDb MDF file on Azure
please config your application to use remote database such as SQL Azure.

OAuth2, Azure, Asp.Net MVC5 Default template, cannot access db

In Asp.Net MVC5, I'm using the default template
I've set customer errors of in web.config. I'm trying to connect to google and facebook. When I deploy to azure, i get the following... I've not done anything that I'm aware of locally to prepare the DB. Although I do have sql express installed for other reasons.
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.
If I recall correctly when deploying to azure you need to specify a connection string for your project to connect to. In Azure you cant use the DefaultConnection string as it designed only to work locally

umbraco deployment in azure websites and sql azure

I am new to umbraco and I tried to create an application using it . I created an empty mvc application in visual studio 2013 and add UmbracoCms nuget package( Version 7.1.4). When I ran the app it asked for installation and is successfully installed in a local SQL CE database.
I added the required Controller ( inheriting SurfaceController) and the model required in my partial view . The project compiled and the page worked fine.
Now I need to deploy this site to Microsoft azurewebsites. When I publish the site from visual studio publish option(I specify the website name, sql azure db name and credentials ) to azure the whole publish process gets successfully done. When I browse the site it goes the page that reads "Looks like there's still work to do" and when I click the "Set up your new website" button it goes to the login page "http://XXXXX.azurewebsites.net/umbraco#/login/false". I don't have the credentials since this is a new deployment and I also tried the local one but it did not work either. I believe that the sql azure db is not setup for this. I was of the opinion that when I run the site it willl take me to the installation page . But it did not.
Any help on this would be really appreciated.
Thanks.
Since you installed umbraco locally with SQL CE the web.config gets updated with the current version (its an appSetting) and a connection string. When you then deploy that to Azure it will look like the site is already setup.
Now, I don't know if you included the SQL CE database in your deployment package because with that the site would work (with the credentials you choose locally). But ideally you'd want to set it up with a SQL azure database. To do this you can "reset" the umbracoDbDsn connection string in web.config and remove the version in appSettings. Doing that will make Umbraco start the installation when deployed to azure.
In the umbraco installer you simply choose Customize to get the dialog that always you to enter a connection string for SQL azure.

Resources