Loading large SQL Server CE databases on WP7

Recently I ran into an issue when trying to load the large database (approx. 50 mb) from isolated storage on WP7. Whenever I tried to query the Data Context, I got the following SqlCeException:

The database file is larger than the configured maximum database size. This setting takes effect on the first concurrent database connection only. [ Required Max Database Size (in MB; 0 if unknown) = 0 ]

After some searching over the web, I found this blog post covering some details of that parameter.

The general work-around is adding ‘Max Database Size’ value (in megabytes) to the connection string, so it looks like:

var connectionString = "Data Source='isostore:DB.sdf'; Max Database Size = 60";

Now your app should be able to init the data context.