AdFactum ObjectMapper .NET Blog

Official blog of the AdFactum ObjectMapper .NET

Exception: NoPrimaryKeyFoundException

Posted by Gerhard Stephan on January 28th, 2008

The NoPrimaryKeyFoundException will be thrown if the user tries to query an entity type which has no valid primary key defined by the PrimaryKey attribute. In case that you use a pre-defined base object like "AutoIncValueObject" or "ValueObject" this exception will never occure.

To solve this exception, include a property to your entity type which is tagged with the PrimaryKey attribute or use a pre-defined base class.

    /// <summary>

    /// Interface that describes a person

    /// </summary>

    public interface IPerson : IValueObject

    {

        /// <summary>

        /// Gets or sets the unique value object id.

        /// </summary>

        /// <value>The unique value object id.</value>

        [PrimaryKey]

        new int? Id

        {

            get;

            set;

        }

 

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>