How to Bin Deploy SQL Compact Edition 4.0 and Razor web projects

How to Bin Deploy SQL Compact Edition 4.0 and Razor web projects

  • Comments 1

With the release of VS2010 SP1 Beta1, Web Matrix,  and Razor QFE, we can build web projects containing SQL Compact Edition 4.0 sdf file and ASP.NET Web Pages with Razor syntax. However, this might be a problem when you are ready to deploy your project on a server that doesn’t have the assemblies required to run SQL CE 4.0 and Razor pages.

To solve this issue, we can make the project “Bin Deployable”, similar to the way we do bin deploy an MVC project. If the hosting machine has ASP.NET 3.5 or later installed, then we just need to include the required assemblies in the bin folder when deploying the project.

We can include required assemblies in a Web site or Web Application project with a few simple steps. You right click the project node in Solution Explorer and select “Add Deployable Dependencies…” context menu item.

MenuItem

If there isn’t SQL CE 4.0 nor Razor installed on the machine, the following dialog will pop up:

image

If there’s at least one of them installed, then the following dialog will pop up:

image

Visual Studio detects what components are present on the machine and the corresponding options will be enabled; you then can choose what to include in the bin folder. In the above picture, only the option for SQL Server Compact is enabled on a machine with SQL Server Compact 4.0 installed. If it’s a website, the required assemblies will be copied to “Bin” folder; if it’s a WAP, they will be copied to “_bin_deployableAssemblies” folder. Note that your selection will not be persisted after the dialog is closed.

Now you can deploy your web projects the same way you deploy any other web project. For a Web Application Project (WAP), you can use Deployment feature made available with VS2010. For both web site or WAP, you can use “Copy Web”, or “Web Deployment Project” to push all the files needed to deploy to a specific directory, test it, and then copy the the host.

Hope it helps!

Thanks,
-Anh

Leave a Comment
  • Please add 3 and 8 and type the answer here:
  • Post
  • I don't see a menu item for Add Deployable Dependencies.  Do I need VS 2010 SP1 Beta1 installed?

    I have an MVC 3 project (w/ Razor) and an SQL Server compact database (.sdf file).

    What are the manual steps to accomplish the same thing?

Page 1 of 1 (1 items)