问题
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
回答1:
They need SQL Server Express installed. Once installed, you need to attach the database file (.mdf) to the server.
回答2:
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.
回答3:
in solution explorer right click on your project
then on new item
then select Serviced based database
create a database and use it
来源:https://stackoverflow.com/questions/5795048/how-to-deploy-mdf-file