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

Deleting tables/views etc from diagram breaks Entity Model

3 Answers 115 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Eric
Top achievements
Rank 1
Eric asked on 05 Mar 2012, 04:59 PM

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?

Thanks!

-Eric

3 Answers, 1 is accepted

Sort by
0
Ivailo
Telerik team
answered on 08 Mar 2012, 05:43 PM
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.

Regards,
Ivailo
the Telerik team
Telerik OpenAccess ORM Q1 2012 release is here! Check out what's new or download a free trial >>
0
Ian
Top achievements
Rank 1
answered on 20 Mar 2012, 02:34 PM
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)

use

 

 

tempdb

GO

if

 

 

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

GO

create

 

 

view X

WITH

 

 

SCHEMABINDING

AS

(

 

select 1 as a

)

GO

create

 

 

unique clustered index IX_X on X(A)

GO

 


0
Ady
Telerik team
answered on 22 Mar 2012, 03:27 PM
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,
Ady
the Telerik team
Telerik OpenAccess ORM Q1 2012 release is here! Check out what's new or download a free trial >>
Tags
General Discussions
Asked by
Eric
Top achievements
Rank 1
Answers by
Ivailo
Telerik team
Ian
Top achievements
Rank 1
Ady
Telerik team
Share this question
or