FNH supports CE 4.0, try this configuration:
var config = Fluently.Configure() .Database(MsSqlCeConfiguration.Standard.ConnectionString("Data Source=DatabaseFileName.sdf")) .Mappings(m => { m.FluentMappings.AddFromAssembly(typeof(Entity).Assembly); }) .BuildConfiguration();
Assemblies with entity mappings must be added via AddFromAssembly. DatabaseFileName.sdf is the path and file name of the database file name. The path can be either absolute or relative to the application’s working directory (Windows application: System.AppDomain.CurrentDomain.BaseDirectory; web application: System.AppDomain.CurrentDomain.RelativeSearchPath).
Tested on FNH1.0, NH2.1 and SQL Server CE 4.0 .
EDIT: The database file must be created by the database engine:
using (var engine = new SqlCeEngine(connectionString)) { engine.CreateDatabase(); }
Here is an example for CE 3.5, but it should also work with CE 4.0: http://nhdatabasescopes.codeplex.com/SourceControl/changeset/view/f9e824a457e8#DatabaseScopes%2fMsSqlCeInFilePrivateScope.cs .
source share