Updating an Entity Definition

13 posts, 0 answers
  1. Steve
    Steve avatar
    1851 posts
    Member since:
    Dec 2008

    Posted 12 Apr 2011 Link to this post

    Ok I like how the new wizard shows me everything now in a nice list

    But I'm running into the annoyance of it Appending properties to my definitions instead of removing and refreshing.  So we updated a table with a DB constraint.  The wizard showed REMOVE against all the columns then ADD below those showing it needed to re-add them (okay fine).  When I clicked finish, nothing was removed, I had an entity with every column duplicated which means I have to delete and re-map the thing in which also means I lose every custom association I have defined and have to re-drag all those in.

    Why can it not just remove and add as described?...or at least give us a checkbox so I can say "Yep, I'm cool with that happening"
  2. Jordan
    Admin
    Jordan avatar
    547 posts

    Posted 13 Apr 2011 Link to this post

    Hello Steve,

    We are glad to hear that you like the new Update from database wizard.

    Usually, if only a new constraint has been added to the database, the changes should look something like in the attached image. There should not be any removed or added columns. Just a new constraint added to the Constraints collection of the table containing the foreign key.

    Having remove operation for an item (a column for example) and also an add operation for the same (or almost the same) item, usually results from renaming the same item in the database.

    In order to be able help you further I will need to have better understanding about the state of your model before updating and also about the changes in your database.
    It will be best if you can send us a SQL script that creates the database (or just the relevant part of it), and also another SQL script that performs the changes that have to be applied to the model using the Update from database wizard.
    This way I will be able to investigate your exact case locally.

    About updating the model when there are removed items in the database we have some plans to improve the experience there. As always your feedback is most welcome.


    Best wishes,
    Jordan
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. DevCraft banner
  4. Steve
    Steve avatar
    1851 posts
    Member since:
    Dec 2008

    Posted 13 Apr 2011 Link to this post

    I will try and get the rLinq...although you guys probably already have it in a seperate ticket...

    You know what it probably is\was.  OA generated the properties as UserId RuleId and I renamed them to UserID and RuleID...is there some logic in the wizard to not look at the underlying column name or something?  Becasue the wiz didn't say Modify at all, it was X Removes, then X Adds.

    Steve
  5. Jordan
    Admin
    Jordan avatar
    547 posts

    Posted 14 Apr 2011 Link to this post

    Hello Steve,

    Actually, the name of items (columns, tables, etc.) is essential for the Update from database process.
    Currently the name is the most important component when comparing items.
    Because of that when two columns have different names (even if they are almost the same) they are considered different.
    As you can imagine, we cannot know with 100% accuracy which column has been renamed to which other column, and what was the intention of the user.
    This is why in the Update from database wizard a pair of add / remove operations is shown.

    The best we could do here is a suggestion that  a column has been renamed, but ultimately it is up to the user to decide.
    We have some plans to improve the experience in that area, but I cannot share anything specific at the moment.
    As always, your feedback is most welcome.

    Best wishes,
    Jordan
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  6. Steve
    Steve avatar
    1851 posts
    Member since:
    Dec 2008

    Posted 14 Apr 2011 Link to this post

    Is there no attribute in the rLinq which knows the underlying column?...like userId automaps as UserId, so I rename it to UserID...should it still not know UserId&UserID link back to userId? (did that make sense)?
  7. Jordan
    Admin
    Jordan avatar
    547 posts

    Posted 15 Apr 2011 Link to this post

    Hello Steve,

    It depends where you do the renaming.
    If you rename a column or a property in the visual designer the mapping is preserved, since in the visual designer we are in control.

    But if you rename a column or a table in the database, since we do not control that and cannot know what the intention was when you do an Update from database you will get an add/remove pair of operations.

    Or did you mean something else?

    Regards,
    Jordan
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  8. Steve
    Steve avatar
    1851 posts
    Member since:
    Dec 2008

    Posted 15 Apr 2011 Link to this post

    Well yeah :)  I wouldn't expect you to magically match columns names if renamed in the DB table :)

    I meant in the designer...I renamed the columns in the designer to be uppercase.  And I did get the Add\Remove in the update wizard.

    Now our SQL guy has a script which he runs which triggers an ALTER...but the column names (casing) never changed there.

    Steve
  9. Jordan
    Admin
    Jordan avatar
    547 posts

    Posted 19 Apr 2011 Link to this post

    Hi Steve,

    You probably already know that, but just in case:
    If just the names of the properties in the generated code are what concerns you, this can be fixed very easily without any impact on the database by just renaming the properties in the visual designer (and not the columns using the table editor). This way the generated code will look like you want it to, the database schema remains unchanged, and the mapping between database and model is preserved.

    Kind regards,
    Jordan
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  10. Steve
    Steve avatar
    1851 posts
    Member since:
    Dec 2008

    Posted 19 Apr 2011 Link to this post

    Hey Jordan,
      I think you've lost sight of the original issue :) 

    1) I renamed the columns in the designer
    2) DB guy altered the table
    3) Update to the model duplicated all the columns with ADD\REMOVE rows in the wizard
  11. Jordan
    Admin
    Jordan avatar
    547 posts

    Posted 20 Apr 2011 Link to this post

    Hello Steve,

    Thank you for the clarification.

    It will also be helpful to know exactly what did you do in order to rename columns in the visual designer.

    Anyway, if your DB guy renamed columns in the database (to something different than in the model) then it is completely normal to get the add / remove operations.

    All the best,
    Jordan
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  12. Steve
    Steve avatar
    1851 posts
    Member since:
    Dec 2008

    Posted 20 Apr 2011 Link to this post

    Click then Property, change the name in the Properties pane in VS2010...thats all

    DB Admin did not change the names of the columns at all
  13. Jordan
    Admin
    Jordan avatar
    547 posts

    Posted 21 Apr 2011 Link to this post

    Hello Steve,

    Actually what you did (using the property grid in the visual designer) is rename the property, which has no effect whatsoever on the associated column. You can use the Mapping Details Editor tool window to see the columns mapped to the properties of a given class. There you should also see that the column names have not changed. So this should not be the reason for the add / remove operations in the Update from database wizard, because there only the relational parts (tables, columns, etc.) of models are compared.

    Note:
    Currently, the only way to change the name of a column is by using the Table editor (right click on class' header in the visual designer > Edit Table...).

    In order to be able to help you further I will need to have better understanding about your model and how it was changed. It will really help if you can send at least the relevant parts of your model before and after it was changed. SQL scripts defining the database schema (before and after) may also help.

    Regards,
    Jordan
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  14. Steve
    Steve avatar
    1851 posts
    Member since:
    Dec 2008

    Posted 21 Apr 2011 Link to this post

    I realize that all I was doing was superficially changing the model property names (not affecting the DB tables)...that was what I was attempting to do. 

    So that's why I posted this...becasue it was so odd.  I was expecting that an ALTER to the table by our DB guy to add in a simple constraint would not delete and re-add (duplicate) all of my properties.

    So might as well just close this, I can manually fix it where needed, and now I know to at least watch for the strangeness
Back to Top
DevCraft banner