No changes are saved to SQLCE Database

Original Post Chris's Avatar

Chris

11 May, 2010 02:00 PM via web

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?

  1. 2 Posted by Chris on 12 May, 2010 09:27 AM

    Chris's Avatar

    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!

  2. James Gregory resolved this discussion on 16 May, 2010 05:04 PM.

Comments are currently closed for this discussion. You can start a new one.

Recent Discussions

05 Jul, 2010 10:29 PM
05 Jul, 2010 12:45 PM
05 Jul, 2010 12:42 PM
05 Jul, 2010 12:17 PM
05 Jul, 2010 12:12 PM

 

03 Jul, 2010 12:26 AM
02 Jul, 2010 02:17 PM
02 Jul, 2010 08:18 AM
02 Jul, 2010 12:20 AM
01 Jul, 2010 10:14 PM