Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Entity Framework - Mapping 1 to Many

Entity Framework - Mapping 1 to Many

Scheduled Pinned Locked Moved Visual Basic
securityregexhelpquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nlarson11
    wrote on last edited by
    #1

    Hello, Forgive if this is in the wrong forum. I didn't see a better one to use. i'm confused on the mapping of a 1 to many. I have 1 table with a primary key of userid. I have another table with the primary key of userid and authid. I created an association of a 1 to many (because one user record to many occurrances of security authorizations for that user). When I assign userid to userid - that's fine but obviously I don't have a match for authid -> and the compiler isn't happy about that. So how does 1 to many work or am I missing something :omg: - in order to have a many, the primary key can't match because it 2nd tables record's primary key has to be unique? Any help would be appreciated. Nathan

    'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous

    L M 2 Replies Last reply
    0
    • N nlarson11

      Hello, Forgive if this is in the wrong forum. I didn't see a better one to use. i'm confused on the mapping of a 1 to many. I have 1 table with a primary key of userid. I have another table with the primary key of userid and authid. I created an association of a 1 to many (because one user record to many occurrances of security authorizations for that user). When I assign userid to userid - that's fine but obviously I don't have a match for authid -> and the compiler isn't happy about that. So how does 1 to many work or am I missing something :omg: - in order to have a many, the primary key can't match because it 2nd tables record's primary key has to be unique? Any help would be appreciated. Nathan

      'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      nlarson11 wrote:

      Forgive if this is in the wrong forum. I didn't see a better one to use.

      How about the one titled Database[^]?

      Binding 100,000 items to a list box can be just silly regardless of what pattern you are following. Jeremy Likness

      1 Reply Last reply
      0
      • N nlarson11

        Hello, Forgive if this is in the wrong forum. I didn't see a better one to use. i'm confused on the mapping of a 1 to many. I have 1 table with a primary key of userid. I have another table with the primary key of userid and authid. I created an association of a 1 to many (because one user record to many occurrances of security authorizations for that user). When I assign userid to userid - that's fine but obviously I don't have a match for authid -> and the compiler isn't happy about that. So how does 1 to many work or am I missing something :omg: - in order to have a many, the primary key can't match because it 2nd tables record's primary key has to be unique? Any help would be appreciated. Nathan

        'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous

        M Offline
        M Offline
        Mycroft Holmes
        wrote on last edited by
        #3

        I would guess that your composite primary key is incorrect. Ask this question, can a user have multiple types of authorisations. If yes then you need a many to many link User - UserID Authorisation - AuthID Link - LinkID - unique constraint (userid/authid) I hate composite primary keys - personal bias only!

        Never underestimate the power of human stupidity RAH

        N 1 Reply Last reply
        0
        • M Mycroft Holmes

          I would guess that your composite primary key is incorrect. Ask this question, can a user have multiple types of authorisations. If yes then you need a many to many link User - UserID Authorisation - AuthID Link - LinkID - unique constraint (userid/authid) I hate composite primary keys - personal bias only!

          Never underestimate the power of human stupidity RAH

          N Offline
          N Offline
          nlarson11
          wrote on last edited by
          #4

          Thank you for your reply. Yes, a person can have 1-N authorizations. I guess i'm still confused with 1 to many in this context. From the user record, I wanted to include the auths table to get at the auths relating to that person. In order to have a 1 to many, the 2nd table must have an additional field(s) defined as the primary key for uniqeness. But EF seems to want a matching of 1-1 of primary keys. Not sure how that's can be. Unless there's something about the mapping I completely am overlooking. Nathan

          'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous 'Life's real failure is when you do not realize how close you were to success when you gave up.' ~ anonymous

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups