I am new to NHibernate and MVC too.
I have a model class which contains properties like
public class RegisterViewModel
{
[Required]
[Display(Name="Full Name")]
public string Name { get; set; }
[Required]
[Display(Name = "Email Id")]
public string EailID { get; set; }
[Required]
[StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 1)]
[DataType(DataType.Password)]
[Display(Name = "Password")]
public string Password { get; set; }
[DataType(DataType.Password)]
[Display(Name = "Confirm password")]
[Compare("Password", ErrorMessage = "The password and confirmation password do not match.")]
public string ConfirmPassword { get; set; }
}
I have created xml mapping file for this model is like below.
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
auto-import="true" assembly="EventMgnt" namespace="EventMgnt.Models">
<class name="EventMgnt.Models.RegisterViewModel" table="tblUser" dynamic-update="true" >
<cache usage="read-write"/>
<id name="Id" column="Id" type="int">
<generator class="native" />
</id>
<property name="Name" />
<property name="EmailID" />
<property name="Password" />
<property name="ConfirmPassword" />
</class>
</hibernate-mapping>
And i am getting Could not compile the mapping document error. Now I have few questions that,
- Is it neccessary to write all properties which are available in model class in Nhibernate xml mapping file?
- What if i do not have 1 column in database of confirm password?
Any help would be grateful.