ASP.NETMVC4アプリケーションでコードファーストエンティティとマッピングを使用してPostgreSQLとFluentNHibernateを使用しています。
アプリケーションを実行すると、データベースからすべてのレコードが自動的に削除されます。
これは私のNHibernateHelperクラスです
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();
}
間違った構成はありますか?