Can anybody help me. My aim is, to use always the same database. By me it overrides all my data. I get this error: An invalid or incomplete configuration was used while creating a SessionFactory. Check PotentialReasons collection, and InnerException for more detail.
My Code look like:
using FluentNHibernate; using NHibernate; using FluentNHibernate.Cfg; using FluentNHibernate.Cfg.Db; using FluentNHibernate.Automapping; using NHibernate.Cfg; using NHibernate.Tool.hbm2ddl; using NHibernate.Criterion; using FluentNhibernateTest; using FluentNHibernate.Mapping; using MMAdminPfyn.MappingFiles;
namespace FluentNhibernateTest { public sealed class FluentNHibernateHelper { private static ISessionFactory sessionFactory;
public static ISessionFactory GetInstance() { if (sessionFactory == null) { sessionFactory = BuildSessionFactory(); } return sessionFactory; } private static ISessionFactory BuildSessionFactory() { return Fluently.Configure() .Database(PostgreSQLConfiguration.PostgreSQL82 .ConnectionString(c => c .Host("localhost") .Port(5432) .Database("blablabla") .Username("blablabla") .Password("blablabla"))) .Mappings(m => m.FluentMappings .AddFromAssemblyOf<AdresseMap>() .AddFromAssemblyOf<PersonMap>() .AddFromAssemblyOf<InstitutionMap>() .AddFromAssemblyOf<LiteraturMap>() .AddFromAssemblyOf<KategorieMap>() .AddFromAssemblyOf<MediaDateiMap>() ) .ExposeConfiguration(BuildSchema) .BuildSessionFactory(); } private static void BuildSchema(Configuration config) { new SchemaExport(config).Create(true,
true); } } }