Deleting tables/views etc from diagram breaks Entity Model

4 posts, 0 answers
  1. Eric
    Eric avatar
    4 posts
    Member since:
    Jan 2012

    Posted 05 Mar 2012 Link to this post

    Hi all,

    Just learning to use (and greatly appreciating!) the Open Access ORM.  However, I'm repeatedly running into a problem that may be due to my inexperience, but, wanted to know if others run into this as well.

    Here is what happens: I create an entity model from my SQL Server database. The entity objects are all populated on the model, with relationship links all appearing.

    1) It appears that even though I create indexed views in the database (even specifying a primary, clustered index), I get errors that the Open Access entity model lackes primary keys on these views. Is that normal, or as designed?

    2) It also seems that once you create the model, don't touch it! If I delete an object from the model by deleting it from the model entity relationship diagram, it causes havoc. I have to manually delete other objects elsewhere that mapped to these objects I just deleted. Even then, it seems sometimes the only way to fix, is to totally delete the Entity Model and start again.

    So... I'm guessing since I'm new to this I'm probably shooting myself in the foot when I do these things. Or, is this normal?



  2. Ivailo
    Ivailo avatar
    318 posts

    Posted 08 Mar 2012 Link to this post

    Hello Eric,

    Thank you for your interest in OpenAccess ORM.

    To address your questions:
    1) At the moment we do require primary keys to be defined for the views explicitly in the model. This is something we will probably improve in the future. For the time being, you can either select the primary key manually in the Visual Designer, or you can use the Validation dialog to perform this automatically (it will open if you double click on any of the warnings about the missing primary keys). For more information, refer to this article.

    2) In general, deleting schema items in the database is not possible through OpenAccess. We had to make sure that no unwanted deletions occur, so it is indeed a bit of an overhead when you actually want to delete a table or a column. Furthermore, deleting a persistent class does not necessarily mean that the underlying table object in the model should be removed - for instance, you can drag the table from the Model Schema Explorer to the designer surface and you will restore the class without even reading the database again.

    In any case, if you experience some strange behavior in the Visual Designer, let us know and we can either resolve it or provide a workaround if it's a bug.

    the Telerik team
    Telerik OpenAccess ORM Q1 2012 release is here! Check out what's new or download a free trial >>
  3. DevCraft banner
  4. Ian
    Ian avatar
    26 posts
    Member since:
    Jun 2012

    Posted 20 Mar 2012 Link to this post

    If this is SQL Server, how do you make an indexed view that has a primary key?  I know you can make an indexed view and give it a unique clustered index which is pretty much the same thing.  Is that what you meant?  If so, it sounds reasonable for OA to recognise this pattern and follow along.

    If I'm wrong please do correct me - I'd like to add the primary key on a view trick to my knowledge.

    Example of what I had in mind  (formatting may come across awful - apologies)









    object_ID('X') is not null drop view X





    view X








    select 1 as a






    unique clustered index IX_X on X(A)



  5. Ady
    Ady avatar
    588 posts

    Posted 22 Mar 2012 Link to this post

    Hi Vermon,

     You are right. It is possible to create an indexed  view but you cannot create a primary key on a view. OpenAccess at the moment reads indexes defined on all tables and hence even if there is a unique clustered index defined on the view it is not detected by OpenAccess.
    We have plans to implement 'primary key detection' for views and once this is done the views would get the primary keys on them.

    All the best,
    the Telerik team
    Telerik OpenAccess ORM Q1 2012 release is here! Check out what's new or download a free trial >>
Back to Top