SQL Server Express is a development time database and it is not recommended to use it on your production server. The rationale for providing SQL Express edition was to ensure that development can be done without having to install a licensed copy of SQL Server on your development machine…
Additionally most of the hosters do not support SQL Server Express on their shared web servers and enterprises are typically running on full SQL Server in their Staging/Production environment.
When you are developing a Web Project using Visual Studio then your SQL Express MDF file is put inside App_Data folder. VS also ensures that App_Data folder is set up with the correct read/write access so that your application can then write to the Database files in it…
When it comes time to deploy your application you should ensure that your MDF files do not get deployed with the rest of your application. To help with this VS provides option to exclude the content of App_Data folder.
Web Application Projects (VS 2005/ VS 2008)
If you are using Web Application Projects in VS 2005/VS 2008 then when your right click on your project and hit “Publish” then the option to Exclude the content of App_Data is available as a checkbox as shown below:
Web Application Projects (VS 2010)
In VS 2010 web deployment is hugely improved… As part of the clean up this option is now moved to project properties as shown below:
When project properties window opens then navigate to Package/Publish tab… In this tab there is a checkbox which allows you to exclude “App_Data” content while publishing…Check the box as shown below:
With this setting Visual Studio 2010 will make sure that your Web Deployment does not includes content of App_Data folder… If you would like to learn more, check out the rest of the properties of Package/Publish tab…
Are there scenarios to not exclude App_Data folder all the time?
Sometimes I have been asked why to give a specific option to Exclude App_Data folder and not exclude it all the time by default.
Well people also put bunch of other files in App_Data folder for e.g. XML files which your web updates or other flat file DBs that your web might potentially use… In this scenario excluding App_Data would exclude those files too and you would ideally want to avoid that, hence there is an explicit option to leave out the content of App_Data folder…
Hope this helps!!