Fluent NHibernate automatically deletes data

I am using PostgreSQL and Fluent NHibernate with first entity and mapping codes in an ASP.NET MVC4 application.

When I run the application, it automatically deletes each entry from the database.

This is my NHibernateHelper class

public class NHibernateHelper
{
    private static ISessionFactory _sessionFactory;

    private static ISessionFactory SessionFactory 
    {
        get 
        {
            if (_sessionFactory == null)
                InitializeSessionFactory();
            return _sessionFactory;
        }
    }

    private static void InitializeSessionFactory()
    {
        _sessionFactory = Fluently.Configure()
            .Database(PostgreSQLConfiguration.Standard
                        .ConnectionString(
                            @"Server=localhost;Port=5432;Database=TestDB;User=postgres;Password=postgre;")
                        .ShowSql()
            )
            .Mappings(m => m.FluentMappings.AddFromAssemblyOf<ProductCategory>())
            .ExposeConfiguration(cfg => new SchemaExport(cfg)
                            .Create(true, true))
            .BuildSessionFactory();
    }

    public static ISession OpenSession() 
    {
        return SessionFactory.OpenSession();
    }

Is there an incorrect configuration?

+2
source share
1 answer

I would say that the problem is here:

.ExposeConfiguration(cfg => new SchemaExport(cfg).Create(true,true))

, factory. 100% ( , , ), , , (, - ).

- SQLite Fluent NHibernate, , , ( re) :)

+5

All Articles