If a table has a relationship to another table more than once, use the relationship name

15 posts, 1 answers
  1. AJ
    AJ avatar
    33 posts
    Member since:
    Jun 2011

    Posted 01 Jun 2012 Link to this post

    For example,

    I have an OrderNotes table that has a UserID and NotifyUserID column. Both link back to the Users table.

    When I established the relationship, the name that was generated from SQL was FK_OrderNotes_Users and FK_OrderNotes_NotifyUsers. In SubSonic, this would have generated OrderNote.User and OrderNote.NotifyUser properties. However, in OpenAccess, I get a much less helpful "User" and "User1".

    The temporary solution, from what I can tell, is going into the Visual Designer finding the relationship so I can determine if I need to rename the User or User1 properties and then actually rename the property name accordingly. In this case, I renamed User1 to NotifyUser.

    Thanks,
    Andrew
  2. Answer
    Alexander
    Admin
    Alexander avatar
    727 posts

    Posted 06 Jun 2012 Link to this post

    Hello Andrew,

    You are right, currently the name generator does not take into account the foreign key column/property name but only the name of the targeted class in the association. In case of multiple relations to the same class, a number is added to the the navigational property name.

    We will consider your suggestion as a feature request and will add it to our backlog system, however I am not able to give you a time-frame when this functionality will be implemented.
    Thank you for your feedback, it is highly appreciated.

    Kind regards,
    Alexander
    the Telerik team
    Follow @OpenAccessORM Twitter channel to be the first one to get the latest updates on new releases, tips and tricks and sneak peeks at our product labs!
  3. DevCraft banner
  4. Steve
    Steve avatar
    1851 posts
    Member since:
    Dec 2008

    Posted 18 Jun 2012 Link to this post

    +10 on this...it's a painful way to generate the names in a LARGE model with lots of nav properties.  This is one of the reasons I need to maintain a separate unit test to do nothing but validate the model....because we do rename "User1" to whatever it should be in the first place.  So if I ever unmap\remap the class it becomes "User1" again.
  5. Alexander
    Admin
    Alexander avatar
    727 posts

    Posted 21 Jun 2012 Link to this post

    Hello Steve,

    We will raise the priority of this entry, hopefully we will be able to implement it for Q3 later this year.

    Greetings,
    Alexander
    the Telerik team
    OpenAccess ORM Q2'12 Now Available! Get your hands on all the new stuff.
  6. Steve
    Steve avatar
    1851 posts
    Member since:
    Dec 2008

    Posted 21 Jun 2012 Link to this post

    I'm so happy on this :)  After everything put into Q2 2012, there isn't much more on my wishlist, but this is defiantly one :)
  7. Murilo
    Murilo avatar
    17 posts
    Member since:
    Jul 2012

    Posted 22 Jul 2012 Link to this post

    did someone find a less painful way to rename the navigation property names until the q3? Almost every table in our database has a relationship with users and it's been a hell to rename them :|
  8. Murilo
    Murilo avatar
    17 posts
    Member since:
    Jul 2012

    Posted 22 Jul 2012 Link to this post

    Hey, how can I send my project to this thread so people can download it from here?

    I just developed a tool to help me out while there is nothing official from telerik. I will share it here because it might be of public interest.


    The tool was developed based on 2012.2.607.1 version of orm, I dont know if there were changes in the template.

    This tool can only be used if you are using Fluent Mapping

    This tool WILL NOT alter anything in your model, it will only READ AS TEXT your model and fluent mappings to suggest you new names so you can rename them easily. See images for results

    Instructions:

    1. Download the project
    2. Open the bin/debug folder
    3. Locate the app.config file
    4. Edit the paths with the paths to your orm files (.rlinq and FluentMetadataSource)
    5. Open PropertyNamesSavior.exe
    6. Optional - You can edit the paths now if you want
    7. Optional - You can put file filters on the third textbox, filter format: class1, class2, class3
    8. Click the button to generate name suggestions

    Hope it help you guys like it helped me.

    Let me know if someone has doubts or problems.

    Feel free to edit the project to your own needs :-)

    Project download:
    http://www.4shared.com/rar/xkQ4YsIu/SaviorOfThePropertyNames.html 


  9. AJ
    AJ avatar
    33 posts
    Member since:
    Jun 2011

    Posted 23 Jul 2012 Link to this post

    That looks very interesting and I would love to test it out, but the link provided says that the download is unavailable :(
  10. Murilo
    Murilo avatar
    17 posts
    Member since:
    Jul 2012

    Posted 23 Jul 2012 Link to this post

    Fixed the link, hope it helps

  11. egoren
    egoren avatar
    11 posts
    Member since:
    Apr 2009

    Posted 25 Oct 2012 Link to this post

    We definitely need this feature.  

    Or we need a way to select the relation used for a specific field of the entity instead of trying to figure out what line (relation) correspond to which field.  When you have multiple relations between entities it's just impossible to work with OpenAccess.

    For example we have an entity that has 9 relations to the 'User' entity and may be 30 other relations to other entities.  Person also has 30 other relations to other entities so it is impossible to figure out what Person1...Person9 uses as a relation.   If the database foreign key was used it would be a lot easier for us.

    I have joined a screenshot of what ous schema looks like in OpenAccess so you can see how much we suffer.

    Thanks
  12. Alexander
    Admin
    Alexander avatar
    727 posts

    Posted 29 Oct 2012 Link to this post

    Hi Eyal Goren,

    This functionality couldn't make it for the Q3 version but you can expect it in the Q1 2013 release.
    In the meantime (for one of the following service packs) we are going to add a context-menu command on the navigational members, which you will be able to use to edit the member's association.

    Kind regards,
    Alexander
    the Telerik team
    Telerik OpenAccess ORM Meets ASP.NET Web API. Read more.
  13. AJ
    AJ avatar
    33 posts
    Member since:
    Jun 2011

    Posted 29 Oct 2012 Link to this post

    Alexander -- That sounds like a great first step in the right direction! Can't wait for that to be released.
  14. egoren
    egoren avatar
    11 posts
    Member since:
    Apr 2009

    Posted 02 Nov 2012 Link to this post

    I totally agree with AJ this contextual menu would save us a LOT of time.

    Can you let us know when it's available we will be planning an update as soon as it is available.

    Thanks


  15. Alexander
    Admin
    Alexander avatar
    727 posts

    Posted 07 Nov 2012 Link to this post

    Hi Eyal,

    The new command will be available in the upcoming service pack, expected by the end of the month.
    I will update this thread once the build is available.

    Greetings,
    Alexander
    the Telerik team
    Telerik OpenAccess ORM Meets ASP.NET Web API. Read more.
  16. Alexander
    Admin
    Alexander avatar
    727 posts

    Posted 13 Dec 2012 Link to this post

    Hi guys,

    The service pack (2012 Q3 SP1) is now available for download and contains the new context menu command for editing associations.

    Regards,
    Alexander
    the Telerik team
    Telerik OpenAccess ORM Meets ASP.NET Web API. Read more.
Back to Top
DevCraft banner