Hi all,
I've been trying to set up NHibernat in VS 05/ASP.Net 2.0 and I am having getting an 'Unknown Entity' error when I try to add to the db.
I've read through the forums and followed as much advice as I can, but I'm not sure what's going wrong.
I've set up my classes, with .hbm.xml files (set to embedded resource), in a seperate class dll as per
http://nhibernate.sourceforge.net/forum ... .php?t=514, and used the code at the bottom of that example to load the .hbms.
The Person.hbm.xml file looks like this:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="classes.Person, classes" table="customers">
<id name="id" type="Int64">
<generator class="identity"/>
</id>
<property name="name_last"/>
[properties..........]
As per the forum message above, the code to load this is
NHibernate.Cfg.Configuration cfg = new NHibernate.Cfg.Configuration();
Assembly assm = Assembly.GetExecutingAssembly();
ResourceManager Rm = new ResourceManager("", assm);
string[] names = assm.GetManifestResourceNames();
foreach (string name in names)
{
if (name.EndsWith("hbm.xml"))
{
Stream XmlInputStream = assm.GetManifestResourceStream(name);
XmlTextReader reader = new XmlTextReader(XmlInputStream);
cfg.AddXmlReader(reader);
}
}
factory = cfg.BuildSessionFactory();
Any idea what i'm doing wrong? Any help appreciated.
Thanks, Stuart