code first method - triggers and unique key

2 posts, 1 answers
  1. Håkan
    Håkan avatar
    29 posts
    Member since:
    Apr 2012

    Posted 26 Aug 2012 Link to this post

    Hi All,

    1. We use OpenAccess code first method. How can we create triggers using this.
    (Without doing it manually)

    2. And also how can we create unique key from this code first method (what is the annotation).

    Development team
  2. Answer
    Zoran avatar
    534 posts

    Posted 29 Aug 2012 Link to this post

    Hello Development Team,

     OpenAccess can't generate custom triggers, nor unique key constraints on any column defined by the user. There is no metadata that can describe such database objects and they are not maintained. However, some backends require certain types of triggers in order to generate auto-incremented primary keys, like Oracle for example. If you would like to have a field marked as primary key, to generate a unique-key constraint and the according trigger so it inserts auto-incremented numbers calculated on the database server, this will automatically be done by OpenAccess, you just need to specify which is the identity field and to set Autoinc as the key generator for the entity. Other than this, custom triggers and unique keys can't be defined using any OpenAccess mapping, and should be manually added by the user after the database has been created.

    All the best,
    the Telerik team
    Follow @OpenAccessORM Twitter channel to be the first one to get the latest updates on new releases, tips and tricks and sneak peeks at our product labs!
  3. DevCraft banner
Back to Top