An item with the same key has already been added.
Posted
by senzacionale
on Stack Overflow
See other posts from Stack Overflow
or by senzacionale
Published on 2010-03-13T10:19:56Z
Indexed on
2010/03/13
10:35 UTC
Read the original article
Hit count: 476
c#
|nhibernate
Can someone advice me how to prevent this error. An item with the same key has already been added.?
// Failed to find a matching SessionFactory so make a new one.
if (sessionFactory == null)
{
Check.Require(File.Exists(sessionFactoryConfigPath),
"The config file at '" + sessionFactoryConfigPath + "' could not be found");
Configuration cfg = new Configuration();
cfg.Configure(sessionFactoryConfigPath);
/*MINE*/
var persistenceModel = new PersistenceModel();
persistenceModel.AddMappingsFromAssembly(Assembly.Load("EMedicine.Core"));
persistenceModel.Configure(cfg);
/*END_OF_MINE*/
// Now that we have our Configuration object, create a new SessionFactory
sessionFactory = cfg.BuildSessionFactory();
if (sessionFactory == null)
{
throw new InvalidOperationException("cfg.BuildSessionFactory() returned null.");
}
if (sessionFactoryConfigPath != null) sessionFactories.Add(sessionFactoryConfigPath, sessionFactory);
}
Error is here: sessionFactory = cfg.BuildSessionFactory();
© Stack Overflow or respective owner