Update Database From Model error

2 posts, 1 answers
  1. Steve
    Steve avatar
    50 posts
    Member since:
    Apr 2013

    Posted 02 Jun 2013 Link to this post

    Hi,

    Update Database From Model (Create Database & Migrate Database) error, How to solved this problem? Please see screenshots.

    After Migrate Database
    http://s23.postimg.org/u78ufon3f/phpj_HKOt_F.png

    After Create Database
    http://s12.postimg.org/wmbm45lot/php_RQmvv_F.png

    Thanks.
  2. Answer
    Boris Georgiev
    Admin
    Boris Georgiev avatar
    190 posts

    Posted 05 Jun 2013 Link to this post

    Hi,

    You cannot create a Primary Key constraint on a column which contains duplicated values. This operation is not an OpenAccess ORM limitation, it is not supported by the MS SQL Server. Telerik OpenAccess ORM cannot change the values in the column to allow the operation to be executed out of the box. To create a Primary Key constraint you have to make sure in the database that all the values in the chosen column are unique.

    For the second problem, the target database seems to have a table with the same name as the class you are mapping and you are trying to create it again. In case you would like to create a new database instead of updating the same one, please refer to this documentation article. If OpenAccess doesn't ask you to choose the target database explicitly, you have to change the connection string stored in your app.config or web.config file.
    On the other hand, if the database you would like to synchronize your model with does already exist, you can use the Migrate Database option.

    I hope that helps. 

    Regards,
    Boris Georgiev
    Telerik
    OpenAccess Samples Kit boasts 50+ sample applications providing diverse real-life business solutions. Click to read more and see OpenAccess ORM in action.
  3. DevCraft banner
Back to Top