Please help me solve this problem. I just learned this HNibernate. Thank you.
This error occurs: leleapplication2.mapping. User. hbm. xml (2, 2): XML validation error: the "urn: nhibernate-mapping-2.2: nhibdation" element is not declared.
// Here is the Console
Class Program
- {
- Static void Main (string [] args)
- {
- Test ();
- }
- Static void Test ()
- {
- NHibernateHelper db = new NHibernateHelper ();
- ISession session = db. GetSession ();
- Using (var trans = session. BeginTransaction ())
- {
- User user = new User ();
- User. Age = 123;
- User. Name = "janekim ";
- Session. Save (user );
- Trans. Commit ();
- }
- }
// NHibernateHelper help class
Namespace ConsoleApplication2
- {
- Public class NHibernateHelper
- {
- Private ISessionFactory sessffacloud;
- Public NHibernateHelper ()
- {
- Sessffacloud = GetSessionFactory ();
- }
- Private ISessionFactory GetSessionFactory ()
- {
- Configuration config = new Configuration (). AddAssembly (Assembly. GetExecutingAssembly ());
- Return config. BuildSessionFactory ();
- }
- Public ISession GetSession ()
- {
- Return sessffacloud. OpenSession ();
- }
- }
- }
// Here is User. hbm. xml
<? Xml version = "1.0" encoding = "UTF-8"?>
- <Nhib1_xmlns = "urn: nhibernate-mapping-2.2">
- <Class name = "leleapplication2.domain. User, ConsoleApplication2" table = "User"> </class>
- <Id name = "Id" length = "4">
- <Generator class = "vative"> </generator>
- </Id>
- <Property name = "Name">
- <Column name = "Name" sqltype = "nvarchar" length = "50" not-null = "true"> </column>
- </Property>
- <Property name = "Age">
- <Column name = "Age" sqltype = "int" length = "4" not-null = "true"> </column>
- </Property>
- </Nhib.pdf>
// App. config configuration file