I know they support SQL CE. I think they go up to 3.5??? I just downloaded CE 4.0 and I wanted to test it out in my project but I can't get it configured right in FluentNHibernate...
If 4.0 is supported:
What version do I have to download and could someone give me an example of how to implement it?
Microsoft SQL Server Compact 4.0 is a free, embedded database that software developers can use for building ASP.NET websites and Windows desktop applications.
The latest, and last, release is the SQL Server Compact 4.0. As of February 2013 SQL Server Compact Edition had been deprecated; no new versions or updates are planned, although Microsoft will continue to support until July 2021.
(1) Open SQL Server Management Studio, or if it's running select File -> Connect Object Explorer... (2) In the Connect to Server dialog change Server type to SQL Server Compact Edition (3) From the Database file dropdown select <Browse for more...> (4) Open your SDF file.
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 your entity mappings should be added via AddFromAssembly. DatabaseFileName.sdf is path and file name of the database file name. Path can be or absolute or relative to working directory of the application (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 work with CE 4.0 as well: http://nhdatabasescopes.codeplex.com/SourceControl/changeset/view/f9e824a457e8#DatabaseScopes%2fMsSqlCeInFilePrivateScope.cs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With