Frank
Frank

Reputation: 7585

how to deploy .mdf file

I am trying to make an application, which uses a local .mdf database file (not attached to a sql server). Visual Studio says I have to install SQL Server Express before doing that. I was wondering how I can deploy the application to clients' box. Do they also need SQL Server Express installed?

Thanks a lot

Upvotes: 6

Views: 6178

Answers (3)

waqas aziz
waqas aziz

Reputation: 141

in solution explorer right click on your project

then on new item

then select Serviced based database

create a database and use it

Upvotes: 0

Remus Rusanu
Remus Rusanu

Reputation: 294407

Don't deploy MDFs. Have your application use deployment scripts and run the scripts that create the database, as well as scripts that create all the objects in the database. The issue with deploying a binary (an .MDF) is that you won't be able to upgrade it. Come v. 1.1 of your application, you'll face the dilema of how to deploy your new MDF, but preserver all the data your users saved in the old .MDF. This is not a trivial issue. Red Gate is trying to push its contiguous integration solution which uses diff tools to generate maintenance/upgrade scripts. Microsoft is pushing the Database Project which works similarly based on diff comparison done by the vsdbcmd tool. I'm not a fan of diff based tools, they are prone to making bad decisions, I much much more prefer explicit upgrade scripts.

Upvotes: 4

Nik
Nik

Reputation: 7283

They need SQL Server Express installed. Once installed, you need to attach the database file (.mdf) to the server.

Upvotes: 4

Related Questions