Cade
Cade

Reputation: 133

Local MDF to SQL Server Application Migration

I am in the process of designing a database application that will ultimately be a multi-user application. However for ease of development purposes I was planning on using the built in local .MDF file for Visual Studio for now.

Once I am ready to move this into a multi-user environment is it just a matter of moving the .MDF to the server and attaching it, then changing a connection string? Or is it going to be a project in of itself and I am better off just using the SQL Server from the beginning?

Edit: it would be considerably easier for me to do development from the .MDF because I do a lot of work from home and that would mean I need to use VPN (Very slow).

Another option I am considering is to use SQL Server Express on my local machine and then migrate that to the production server when I am ready.

Upvotes: 0

Views: 710

Answers (2)

Bimal
Bimal

Reputation: 380

As already said by Erik, you are already using SQL server.

Just so you know, I'm using the .MDF file for development and once the changes are done, I publish them to production.

To do this, You need to keep following points in mind.

  • You shouldn't use this method to replace/copy data although it is possible.
  • Use this method to copy/update the schema easily.
  • The production database should be accessible from your development machine.
  • You'll need visual studio for publishing the changes

What I follow is below (All the steps are in Visual Studio 2015 Update 3):

  • Make whatever changes you need in the MDF file.
  • Open "SQL Server Object Explorer" in Visual studio (View->"SQL Server Object Explorer")
  • Expand the SQL server node containing your attached database.
  • Right click the name of your database and choose "Schema Compare..."
  • In the window that opens, select the option "Select Target..." from the top bar of the window.
  • Choose the connection to your production if already connected from the drop-down or click "Select connection..." button to connect to your production server.
  • Click "Compare" on the toolbar in the window.

All the schema differences will be listed in the area below the toolbar.

  • Now, you can select the changes you need to publish to production via the check-boxes.
  • Once done, just click the "Update" button on the window toolbar and confirm the update.

The selected changes from your mdf file will be copied to the production database. In case of any error, the errors will be displayed in the results.

Upvotes: 1

Eric Hotinger
Eric Hotinger

Reputation: 9306

You are already using SQL Server. The difference here is whether or not you want to attach it to a JIT SQL Server instance or by connecting directly to a SQL Server instance.

If you plan to use a real SQL Server instance anyways in the future, it's best to just avoid the App_Data folder.

Upvotes: 0

Related Questions