-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Beginner's q: setting up nh in ASP.Net 2.0
PostPosted: Mon Nov 21, 2005 8:20 pm 
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


Top
  
 
 Post subject:
PostPosted: Mon Nov 21, 2005 8:53 pm 
nm, fixed as soon as i posted. I just needed to add the assemblies normally.


Top
  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.