Many to Many Relations

3 posts, 1 answers
  1. Burim
    Burim avatar
    2 posts
    Member since:
    Oct 2006

    Posted 29 Jul 2011 Link to this post

    I am currently evaluating the product and going through the features according to some scenarios I have. One such scenario is the following:

    I have one table Users and one table Roles. I have a many to many relationship between them through a table called UserRoles. I was able to get everything working if the UserRoles table contained only two columns (IDs of the other tables) which also formed the PrimaryKey to the table.
    I need to be able to have more fields in the table UserRoles such as DateCreated, UserCreated etc. Is there a way to accomplish that?

    Best Regards,
    Burim Ratkoceri
  2. Answer
    Ivailo avatar
    318 posts

    Posted 02 Aug 2011 Link to this post

    Hello Burim,

    As far as I understand, you are using the Many to Many association between Users and Roles with a join table UserRoles, so that UserRoles is not present in your model.

    In order to make the additional fields available, you will have to map this relationship using the other option – presenting the UserRoles class in the domain model, so that instead of Many to Many relation between User and Role you will have a diagram like the one attached.

    To achieve that, first go to your Model Schema Explorer and set the IsJoinTable property of the UserRoles table to False. Then drag & drop the table into your diagram and the associations should be automatically created.

    This way you will be able to use any additional fields that come with the UserRoles table.  The only disadvantage is that you won’t have a direct link from a User to the Role and vice versa – you will have to use the UserRoles collection instead.

    I am looking forward to your feedback.

    the Telerik team
    Want to use Telerik OpenAccess with SQL Azure? Download the trial version today. 
  3. DevCraft banner
  4. Burim
    Burim avatar
    2 posts
    Member since:
    Oct 2006

    Posted 02 Aug 2011 Link to this post

    Hi Ivailo,

    Thanks for the response. I was actually quite crazy about the direct link that OpenAccess provided on many to many relations. However I will try the other approach which is not bad either but I kind of miss the direct link :-)

Back to Top