This is a migrated thread and some comments may be shown as answers.

code first method - triggers and unique key

1 Answer 48 Views
Getting Started
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Håkan
Top achievements
Rank 1
Håkan asked on 26 Aug 2012, 09:56 PM

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

1 Answer, 1 is accepted

Sort by
0
Accepted
Zoran
Telerik team
answered on 29 Aug 2012, 03:48 PM
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,
Zoran
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!
Tags
Getting Started
Asked by
Håkan
Top achievements
Rank 1
Answers by
Zoran
Telerik team
Share this question
or