Note that there are some explanatory texts on larger screens.

plurals
  1. PONHibernate Mapping Exception: invalid child element
    primarykey
    data
    text
    <p>I'm having a problem with NHibernate and the mapping file when I try to save my drink object in my MVC application. My mapping file is an embedded resource and my hibernate.cfg.xml is copy always.</p> <p>Here are my class.cs:</p> <pre><code>namespace FrancosPoS.DBMapping { public class drink { public drink() { } public virtual int id { get; set; } public virtual string type { get; set; } public virtual string price { get; set; } } } </code></pre> <p>My XML mapping:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;hibernate-mapping assembly="FrancosPoS.DBMapping" namespace="FrancosPoS.DBMapping" xmlns="urn:nhibernate-mapping-2.2"&gt; &lt;class name="drink" table="drink" lazy="true" &gt; &lt;id name="id"&gt; &lt;generator class="identity" /&gt; &lt;column name="id" sql-type="int(11)" not-null="true" /&gt; &lt;/id&gt; &lt;property name="type"&gt; &lt;column name="type" sql-type="varchar(25)" not-null="true" /&gt; &lt;/property&gt; &lt;property name="price"&gt; &lt;column name="price" sql-type="varchar(8)" not-null="true" /&gt; &lt;/property&gt; &lt;/class&gt; &lt;/hibernate-mapping&gt; </code></pre> <p>By the way, the connection opens and close fine if I don't try to save it on the database.</p> <p>Here is my Solution Explorer:</p> <p><a href="http://db.tt/BD4D4fyA" rel="nofollow">Solution Explorer Image</a></p> <p>And here is the error that is driving me nuts:</p> <pre><code>"Error: NHibernate.MappingException: FrancosPoS.DBMapping.drink.hbm.xml(6,8): XML validation error: The element 'id' in namespace 'urn:nhibernate-mapping-2.2' has invalid child element 'column' in namespace 'urn:nhibernate-mapping-2.2'. ---&gt; System.Xml.Schema.XmlSchemaValidationException: The element 'id' in namespace 'urn:nhibernate-mapping-2.2' has invalid child element 'column' in namespace 'urn:nhibernate-mapping-2.2'.\r\n --- End of inner exception stack trace --- </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload