No changes are saved to SQLCE Database
Hi,
i have a problem with my SqlCe database. Everytime i add or edit date, als seems to be fine. But the changes are not made in the database. It seems like nhibernate is caching them.
Here is a example:
I configure my database like this:
sessionFactory = Fluently.Configure()
.Database(MsSqlCeConfiguration.Standard.ShowSql().ConnectionString(@"Data Source=db\KD.sdf"))
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<Manufacturer>())
.BuildSessionFactory();
Now, i have a simple table with an ID and some varchars.
[DebuggerDisplay("{Name}")]
public class Manufacturer
{
public virtual int Id { get; private set; }
public virtual String Name { get; set; }
public virtual String ShortName { get; set; }
public virtual String Link { get; set; }
}
and my mapping:
public class ManufacturerMap : ClassMap<Manufacturer>
{
public ManufacturerMap()
{
Id(x => x.Id);
Map(x => x.Name);
Map(x => x.ShortName);
Map(x => x.Link);
}
}
now, i add a manufactuer:
using (var session = SessionHelper.OpenSession())
{
using (var trans = session.BeginTransaction())
{
var test_manu = new Manufacturer { Name = "TestManu", ShortName = "TM", Link = "http://www.test.com/" };
session.Save(test_manu);
trans.Commit();
}
session.Flush();
}
that all works fine!
now, when i try to read him, everything is fine:
var test = session.CreateCriteria(typeof(Manufacturer)).List();
now, i close the application, and take a look in the database. nothing in there!
Does anyone have an idea why its empty?
Comments are currently closed for this discussion. You can start a new one.
2 Posted by Chris on 12 May, 2010 09:27 AM
Ok, i solved the problem by myself.
The DB was copied to the bin folder (always copy), and was always overwritten with the empty db from the project!
That was my failure, sorry!
James Gregory resolved this discussion on 16 May, 2010 05:04 PM.