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