Refer to here:
How to bin deploy SQL compact Edition 4.0 and razor web projects
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.
If there isn' t SQL ce 4.0 nor razor installed on the machine, the following diwing will pop up:
If there's at least one of them installed, then the following diwing will pop up:
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 host.
Hope it helps!