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. C#
  4. Entity Framework: EDM assigns primary key to view randomly (or so it seems)

Entity Framework: EDM assigns primary key to view randomly (or so it seems)

Scheduled Pinned Locked Moved C#
questioncsharphelp
4 Posts 2 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.
  • D Offline
    D Offline
    dfn
    wrote on last edited by
    #1

    Hi, I made a view from a few tables. I then imported that view into my Entity Data Model. The EDM assigned Entity Key = true to a column in the view that is not a primary key (the column is not a primary key in the view, and it is not a primary key in the table the view gets it from). Why does the EDM do this? It assigned Entity Key = true to a value that IS an actual primary key (in the table my view looks at) and also to a value that ISN'T a primary key. I can't figure this out. Can anyone help me out? TIA PS -- I apologize if this is not the right forum, but since in the EDM I am dealing with C# code, I thought I'd post it here.

    H 1 Reply Last reply
    0
    • D dfn

      Hi, I made a view from a few tables. I then imported that view into my Entity Data Model. The EDM assigned Entity Key = true to a column in the view that is not a primary key (the column is not a primary key in the view, and it is not a primary key in the table the view gets it from). Why does the EDM do this? It assigned Entity Key = true to a value that IS an actual primary key (in the table my view looks at) and also to a value that ISN'T a primary key. I can't figure this out. Can anyone help me out? TIA PS -- I apologize if this is not the right forum, but since in the EDM I am dealing with C# code, I thought I'd post it here.

      H Offline
      H Offline
      Henry Minute
      wrote on last edited by
      #2

      I can only think, this is not a fact, just my thoughts, that it is trying to create a form of compound key. All EntityTypes must have a key and so it is attempting to create a compund key that it thinks will be unique.

      Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

      D 1 Reply Last reply
      0
      • H Henry Minute

        I can only think, this is not a fact, just my thoughts, that it is trying to create a form of compound key. All EntityTypes must have a key and so it is attempting to create a compund key that it thinks will be unique.

        Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

        D Offline
        D Offline
        dfn
        wrote on last edited by
        #3

        Thanks for your reply. If this is the case, how would I get around it? If I set the column to NOT be a key, I get a mismatch error, suggesting that both fields (EDM and my DB) must be keys.

        H 1 Reply Last reply
        0
        • D dfn

          Thanks for your reply. If this is the case, how would I get around it? If I set the column to NOT be a key, I get a mismatch error, suggesting that both fields (EDM and my DB) must be keys.

          H Offline
          H Offline
          Henry Minute
          wrote on last edited by
          #4

          I very much regret that, I have no idea. I am only just starting out on the EF Highway, which is why I could still remember the stuff, in my previous post. Give it a month or two and I'll have forgotten that as well. :(

          Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

          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