I am trying to migrate a database from SQL Server 2008 to SQL Azure. The database that I am attempting to migrate includes the ASP.NET Membership database (http://www.asp.net/web-forms/tutorials/moving-to-aspnet-20/membership). This database works fine when I run it in my SQL Server 2008 database. However, when I try to authenticate a user against SQL Azure, I receive an error that says:
"Tables without a clustered index are not supported in this version of SQL Server. Please create a clustered index and try again."
However, I'm not sure what to do. When I try to update the index on the aspnet_Applications table, I receive a foreign key problem. I am using the following in an attempt to migrate my non-clustered index to a clustered index:
ALTER TABLE aspnet_Applications
DROP CONSTRAINT PK__aspnet_A__SOMEID
ALTER TABLE aspnet_Applications
ADD CONSTRAINT PK__aspnet_A__SOMEID PRIMARY KEY CLUSTERED(ApplicationId)
Can someone please help me overcome this issue? Thank you!
I had problems with the ASP.NET membership provider tables (non clustered indexes) and missing the "WITH (NOLOCK)" statement on the stored procedure aspnet_Membership_GetNumberOfUsersOnline etc.
The migration tool found here fixed the problems and exported the database to Azure.
http://sqlazuremw.codeplex.com/
It is a nice wizard that connects to your existing SQL Server and migrate the selected database to Azure.
If you can, try to use the ASP.NET Universal Providers For SqlExpress 1.1 (I wish they'd change the name as it is a bit of a misnomer). This is the officially supported method of enabling the SQL membership, role and session providers across both SQL Azure and standalone SQL Server.
Here are a couple of other links for reference:
Scott Hanselman - Introducing System.Web.Providers
SQL Azure Team Blog - Using SQL Azure for Session State
SQL Azure is not the same as SQL Server because not all features are supported. There is a special SQL Azure Membership Script to create the database.
See here: http://support.microsoft.com/kb/2006191/de
I hope this helps.
Greetings.
Related
I'm currently trying to deploy a website with Azure which I did following these steps
https://learn.microsoft.com/en-us/visualstudio/get-started/csharp/tutorial-aspnet-core-ef-step-05?view=vs-2019#publish-to-azure-app-service
however the data from the database didn't get saved, like it did in the video. I think this may be because I have 2 data contexts; one for users and one for general app models.
I believe I have to figure out how to migrate my data from SQL Server Express provided by Entity Framework to Azure.
It seems like it should be doable from this link
but then this one makes it sound like you need a .bak file.
Just want to know if my Visual Studio data can easily transferred to Azure this way. would it be easier to publish my "data tier application" or extract and copy what I need to azure. Kind of overwhelmed at all the documentation trying to find the easiest way the small amount of data for my test website.
How to migrate my data from SQL Server Express provided by Entity Framework to Azure?
No you can not do that, import and export feature is not available with SQL Server Express. You can reference this link: Limitations of SQL Server Express.
As you posted the screen shoot, no function can help you migrate the database to Azure.
So if you really want migrate the database from local SQL Server to Azure, you'd better using the Microsoft SQL Server Management Studio(SSMS). There are so many ways, such as:
Migrate on-premises SQL Server or SQL Server on Azure VMs to Azure SQL Database using the Data Migration Assistant
Tutorial: Migrate SQL Server to a single database or pooled database in Azure SQL Database offline using DMS
Copy data to and from SQL Server by using Azure Data Factory
Migrating SQL Database to Azure SQL Database using SSMS Export/Import
If you are first time to migrate, we suggest to you use the Azure Data Migration Assistant as Alberto Morillo said.
Hope this helps.
Before trying to migrate the database to Azure you need to first verify the database and its objects are compatible to Azure SQL Database. If you don't do that the migration may fail.
My suggestion is to use Azure Data Migration Assistant (DMA) to perform an assessment of your database and make sure there are no blocking points that can make the migration not possible. Make adjustments based on the report generated by the DMA tool and then use any migration method (including extracting\importing a Data-tier Application) to migrate your database to Azure SQL Database. DMA can also migrate your database to Azure SQL Database and for me is the easiest way to do it.
About restoring a native backup to Azure SQL Database, that is not possible. You can export your database as bacpac and then import it to Azure SQL Database, or you can use DMA or Data Migration Service to migrate your databases to Azure SQL Database.
Adding to what is already said . You can dump all the data in txt or csv file and put that in the local drive . In Azure we have the Azure data factory (ADF) , which has a copy activity , this is very powerful and looks like will be good for your scenario . As mentioned before the data types are the key . You will have to install something called integrated Runtime ( IR ) and it should work .
We have added some stored procedures in SQL Server 2012 Management Studio but in our ASP.NET project we can't add them to the Entity Framework, because we can't see them in the list.
It seems to be a problem with the database roles in SQL Server.
Which roles are needed?
You can try to execute the following query:
USE database_name;
GRANT EXECUTE TO [myStoredName];
Also check Grant Permissions on a Stored Procedure
I have a MVC 5 project using visual studio 2013.
How can I add/create a database in azure from visual studio so that EF6 code first can just use and create the models?
I've been browsing server explorer but there is nothing there related to azure.
I think that you need to create the DB in Azure from the Azure control panel. Once it is there, EF can use the connection string for Azure to add tables/data to an existing DB.
Due to the configuration requirements of Azure DB, I haven't found any option but the control panel to do this.
You should create your DB on Azure first then fetch data from Azure SQL same as you access from normal SQL server.
Same process to follow to create models from DB.
We are in the process of developing a new site that we plan to host on Azure. None of us have done this before, so it has raised some interesting challenges.
First, we are using code first and using migrations to update the database. We were having some issues figuring out how to deploy the database to Azure, so we ended up creating a database project.
There are a bunch of Azure specific issues with deployment, and you will get errors if you don't rectify all the valid SQL that Azure doesn't allow you to use.
It seemed to me that you should be able to do code first on the azure site just like we did on the local site, and I found This article that seems to address the issue.
What I am wondering though, is best practices.
I would assume we don't need database projects anymore, but I am not
sure about that. What is the best practice for managing databases
with Visual Studio 2013 and code first.
The approach in the article above seems fine for a system in
pre-production, but once a system is in production and has live
data, is this a recommended approach?
How do you protect yourself from mistakes like somebody accidentally changing a
setting that tells Visual Studio to recreate the database?
Any thoughts or ideas would be appreciated.
First i would like to state from my understanding, when using Entity Framework and you have Enabled Migration, it's only meant for development and it is recommended that you set it to false when deploying your code.
As for deploying to Microsoft Azure, i have only done this using Visual Studio Team Services. The thing about Code-First is that you have no Sql Queries and the database is not deployed right away. So here is what i have done in the past,
Create a blank Sql Query in SQL Management Studio
In Visual Studio Server Explorer expand your database for the
project to table level
Right click on each table and select "Show Table Definition" I wish
we could do this at Database level.
Copy and past the T-SQL to a blank Sql file in SQL Management
Studio. Note that all table queries can fit in one
file, just have to follow T-SQL rules. Connect to your Azure
Database Instance using SQL Management Studio.
Run the SQL Query against the database on Azure. Note that the
sample data you had used in developemnt will not be on your Azure
database at this moment, you will have to create an insert T-SQL and
run it against the Azure database.
Also make sure that your app has the right connection string when deploying to Microsoft Azure and it should connect to you database just fine.
I am building an ASP.NET 3.5 (C#) application and I plan to use the membership and roles security.
I want to set this up on my SQL Server 2008 standard edition and not the default express setting.
How would I go about this?
You can install membership database with this command
aspnet_regsql.exe
at *C:\Windows\Microsoft.NET\Framework\v2.0.50727* (adjust to your path)
You can find more details here
It doesn't matter wich database server version you are using for the ASP.NET security membership/role module, apart from being SQL Server.
To set up manually this security on a server you have to run these scripts:
c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\InstallCommon.sql
c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\InstallMembership.sql
c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\InstallRoles.sql
and configure web.config accordingly (see http://msdn.microsoft.com/en-us/library/6e9y4s5t.aspx).
You may run this scripts using the same database where you have your data, or you can create a new database to store user membership or role related data and run them there.
you need to run aspnet_regsql. That will popup the wizard to configure your new database.
Take the MDF and LDF files created by Express Edition (usually in App_Data) and Attach them to your SQL Server 2008 Instance.
Setup security for the new database (i.e. add a user to the database that will access the database. Make sure to give the appropriate permissions to the user)
Change the connection string in your web.config to point to the new database
Edit: My answer assumes that you're already using your database and just want to migrate it from SQL Express to SQL Standard edition.