Dear all
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
class Employee
{
public int id;
public string name;
public int getID
{
get
{
return id;
}
set
{
id = value;
}
}
public string SayHello()
{
return string.Format("'Hello World!', said {0}.", name);
}
public string getName
{
get
{
return name;
}
set
{
name = value;
}
}
}
|
Emmployee.hbm.xml
App.config
main program:
static void Main(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();
}
static void CreateEmployeeAndSaveToDatabase()
{
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