Non-Integer Primary Key ID Field

2 posts, 0 answers
  1. Brian
    Brian avatar
    40 posts
    Member since:
    Oct 2008

    Posted 09 Feb 2011 Link to this post

    Does OpenAccess ORM support ID fields that are not integer types (i.e. not short, int, long)?

    The reason I ask is that there are some tables with a LOT of additions and deletions over time, so you eventually hit the int.maxValue limit and need to reset the seed through database administration.  There are some tables where we have a natural key that is a nvarchar string, for example.  Suppose the table stores website URL links and the associated IP address of the host.  Ideally, in that case, I would want:
    • An entity model with a URL:String & IP:String field that map to nvarchar and varchar repsectively in the database.
    • URL is set as the primary key, and OpenAcess does not try to go ahead and create its own integer based ID field as it does today (which results in the same problem)
    This not only saves database space for a very large table, but also makes management easier.  I agree that for moderately sized tables, an integer based ID is the best way to go, and it is what I do.
  2. Alexander
    Alexander avatar
    727 posts

    Posted 10 Feb 2011 Link to this post

    Hi Brian Womack,

    There should be no problem to use a string as primary key. You only need to change the Identity setting (from the Properties pane) of the URL property to true and disable it for all other properties. Additionally, the Identity Mechanism of the class should be set to Default. I hope that helps.

    Kind regards,
    the Telerik team
    Accelerate your learning with industry's first Telerik OpenAccess ORM SDK. Download today.
  3. DevCraft banner
Back to Top