Missing System.Data
Q: When I add a reference to System.Data.SqlServerCE.dll I get "Reference required to assembly 'System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' containing..."?
A: This error can be a result of either a missing or invalid reference to the System.Data assembly. In the unusual case that you don't already have a reference to System.Data (ie a missing reference) you can easily add this via the Add Reference dialog.
Although Sql Server CE works on both the desktop and the mobile device the engine is actually two different sets of assemblies (primarily because most desktops are an x86 architecture while most devices are ARM based). As such when you are adding a reference to System.Data.Sqlserverce.dll you need to make sure you add the correct version.
If you install just the Sql Server CE runtime (ie SQLServerCE31-EN.msi) you will see that the desktop assemblies are available at C:\Program Files\Microsoft SQL Server Compact Edition\v3.1. If you add the assembly at this location to a mobile device application you will see a series of error similar to the above. This is because the assembly was compiled against a different version of the System.Data assembly to what is included in the references section of your project. To overcome this issue you need to add a reference from the correct location that is installed as part of the Sql Server CE SDK (ie SSCE31SDK-ENU.msi) at C:\Program Files\Microsoft SQL Server Compact Edition\v3.1\SDK\bin