Abhishek Joshi
Abhishek Joshi

Reputation: 361

How to setup local database from remote database in visual studio asp.net project?

I am working on an ASP.NET project which accessing a remote SQL Server database. My objective is to set up this remote database on my local system.

I have tried 2 ways, but I'm facing problems both ways:

(1) Using SQL Server import and export wizard.

I get an error saying that the connection state is closed, but I am able to fetch all database tables of remote database:

enter image description here

enter image description here

(2) Schema and Data comparison from SQL Server object explorer inside of Visual Studio.

Here I get an error in that database user-related issues are showing. User or group not found:

enter image description here

I have tried other things in the last 4 days also but not found any clue to solve it. I am new to ASP.NET and SQL. Please help. Any helpful answer will always be appreciated. Thanks.

I have tried the Dennis1679's answer, but the following issues are coming.

One or more unsupported elements were found in the schema used as of a data package. Error SQL71564:Error validating element[username]: The element[username] has been orphaned from its login and cannot be deployed.

enter image description here

Upvotes: 0

Views: 1534

Answers (1)

Dennis VW
Dennis VW

Reputation: 3217

Install SQL Server Management Studio, connect to the remote database, right-click on the database, choose export data-tier application. Then connect to your local instance and import data-tier application.

Connect to the remote database:

Login

Right-click on the database choose export data-tier application:

Export data-tier

  • Follow the wizard and save the .bacpac somewhere
  • Connect to your local SQL Server (localdb)\MSSQLLocalDB
  • Choose Import data-tier application
  • Select the previously saved .bacpac and import it. Now your local instance should have the same database

Import data-tier application

Upvotes: 1

Related Questions