Question: When I try to create a new ASP.NET Empty Web Site in Visual Studio Premium 2013 on my windows 8.1 machine, I get the following error message:

Configuring IIS Express failed with the following error:  

Unable to acces the IIS metabase. You do not have sufficient privilege to acces IIS web sites on your machine.

I am aware questions about this error have been asked all around the web numerous times and I have tried every solution I came upon so far, but nothing has worked. I have reinstalled Visual Studio, I have reinstalled IIS several times (and included all options), I have obviously run Visual Studio as administrator and I have navigated to C:\Windows\System32\inetsrv\config\Export and clicked "Continue" on the popups I got (for permission to access the folders).  

I am completely out of ideas and sincerely hope that one of you can help me with my problems, thanks.

Answer: 
[Here](https://msdn.microsoft.com/en-us/library/ms162169.aspx) is a resource for SMO programming, perhaps you will find what you need in the guide. 

I must admit though, administering SQL Server from managed code is not something I would recommend unless your product is aimed at administering SQL Server. Alternatively look at doing this from Powershell and then controlling your scripts/cmdlets from your managed application. 

[Here](https://msdn.microsoft.com/en-us/library/ff878391.aspx) is another resource with a list of cmdlets for managing SQL Server Availability Groups.

Finally [Get Help SQL Server Powershell](https://msdn.microsoft.com/en-us/library/cc281939.aspx)
It differs whether are we moving DB on primary replica or Secondary.
Below mention are the steps for both the replicas...

1.) Primary Replica:- 
Detach DB from all the secondary replicas AG
Detach DB from the primary replica AG
Issue ALter DB T-SQL command for the DB which needs to be moved.
Copy the db files to the new destination.
Attach the DB back on primary replica AG
Attach the DB back on all Secondary replicas AG

2.) Secondary replica:- 
Take a full backup of DB.
Take a t log backup of DB
detach the DB from the AG
restore DB using backup created earlier and restore to destination location.
Attach the DB back to AG