任何人都可以幫助我。我的目標是,始終使用相同的數據庫。通過我,它覆蓋了我所有的數據。我得到這個錯誤:創建SessionFactory時使用了無效或不完整的配置。請參閱PotentialReasons集合和InnerException以獲取更多詳細信息。NHibernate配置問題
我的代碼如下所示:
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); } } }
你是否檢查內部異常說什麼? – Linkgoron 2011-04-23 10:54:05
它說我:{「無法編譯映射文檔:(XmlDocument)」} – user721654 2011-04-23 14:52:03
而且:重複類/實體映射MMAdminPfyn.Objects.Audio(一個瀏覽器) – user721654 2011-04-23 14:52:47