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

Have I broken it?

2 Answers 41 Views
Design Time (Visual Designer & Tools)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Stuart Hemming
Top achievements
Rank 2
Stuart Hemming asked on 21 Dec 2010, 12:20 AM
Being a sucker for punishment, I've decided to have another go with OA.

I've got a new project and have opted to add a domain model from an existing DB in which I have added a single table.

Went through all the steps and got my EntityDiagram.

All OK so far.

Now, my table has a column named 'postaladdress' which OA mapped to a property called 'Postaladdress'.

I went to the DB and changed the name of the column to 'postalAddress' (note the change of capitalization).

I went to the model in VS and, in the Model Explorer, I right-clicked the top-level of the tree and opted to 'Update From Database'. In the resulting dialog, I clicked on 'Apply All' then on 'Finish'.

The model updates, but instead of simply renaming my 'PostalAddress' property to 'PostalAddress', the model ADDS a new property called 'PostalAddress'. The old 'Postaladdress' property is still in the model!

Surely, that can't be right!

There is, I've discovered, a workaround and that is, in the Schema Explorer, remove and then remap the persistent class.

--
Stuart 

2 Answers, 1 is accepted

Sort by
0
Accepted
Alexander
Telerik team
answered on 21 Dec 2010, 05:17 PM
Hi Stuart Hemming,

In fact this is the expected behavior. When a column (or table) is renamed in the database we cannot really be sure that this has happened, the database gives no information about such changes. However, by comparing the schema before and after we see that one of the old columns is missing and new one has been added. The default action we would perform in this case is add a property to map the new column. The old property will not be deleted in order to preserve the changes you might have done there, but it will be left unmapped. You can see that the old property is not associated with a column in the Mapping Details Editor.

If you would like to use the old property with the renamed column you can use the Details Editor to unmap the newly generated property and map the column to the old one. You can then remove the new property (just delete it from the diagram) and rename the old one if needed.

There is also another way to update the model when something has been renamed in the database. If you have not already run the Update From Database wizard, open it and follow the instructions in this article, under the Modify section. This way you will be able to merge the Add and Remove actions into a single Modify action and update the old column instead of adding new one.
Hope that helps.

All the best,
Alexander
the Telerik team
Accelerate your learning with industry's first Telerik OpenAccess ORM SDK. Download today.
0
Stuart Hemming
Top achievements
Rank 2
answered on 21 Dec 2010, 05:38 PM
Alexander,

Thanks.

-- 
Stuart
Tags
Design Time (Visual Designer & Tools)
Asked by
Stuart Hemming
Top achievements
Rank 2
Answers by
Alexander
Telerik team
Stuart Hemming
Top achievements
Rank 2
Share this question
or