I`m using PostgreSQL and Fluent NHibernate with code first entities and mappings in ASP.NET MVC4 Application.
When i run application it automatically deletes every record from 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 any incorrect configuration?