i am new user to use Nhibernate in dotnet . currently i am create new console project using Nhibernate to mapping table in database to class on my project . i get the error like that :"Unknown entity class: NhibernateConsole.Employee"
i am also adding reference Nhibernate.dll to my project and creating xml file to mapping, but it is get the error.
My project looks like that :
Employee.css
C#
classEmployee
{
publicint id;
publicstring name;
publicint getID
{
get
{
return id;
}
set
{
id = value;
}
}
publicstringSayHello()
{
returnstring.Format("'Hello World!', said {0}.", name);
}
publicstring getName
{
get
{
return name;
}
set
{
name = value;
}
}
}
Emmployee.hbm.xml
Code
App.config
Code
main program:
C#
staticvoidMain(string[] args)
{
//Employee fred = new Employee();//fred.name = "Tran Tuan Van";//Console.WriteLine(fred.SayHello());
CreateEmployeeAndSaveToDatabase();
// UpdateTobinAndAssignPierreHenriAsManager();// LoadEmployeesFromDatabase();
Console.WriteLine("Press any key to exit...");
Console.ReadKey();
Console.ReadKey();
}
staticvoidCreateEmployeeAndSaveToDatabase()
{
Employee tobin = new Employee();
tobin.name = "Tobin Harris";
tobin.id = 1;
using (ISession session = OpenSession())
{
try
{
using (ITransaction transaction = session.BeginTransaction())
{
session.Save(tobin);
transaction.Commit();
}
}
catch (Exception ex)
{
}
Console.WriteLine("Saved Tobin to the database");
}
}
Please anyone can be give me suggestion ?
thanks and best regards
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
Jean PaulRank #32 · 38.5K reputationPosted Feb 3, 2011, 3:10 AM EST
0
The attachments are not complete, so we cannot try resolving it.
Can you attach the necessary files like hbm.xml, config, cs etc as a separate zip file.
Jean PaulRank #32 · 38.5K reputationPosted Feb 3, 2011, 3:10 AM EST
Can you attach the necessary files like hbm.xml, config, cs etc as a separate zip file.
Also, please let us know the NHibernate version.