EF 4.1 Code First Mapping to FK only RRS feed

  • Question

  • Hello, can anyone example how the fluent mapping would work for a table with FK only... no primary key.  

    I tried inventing an ID and set DBOption.None, but that does not work - seems to want me to define that column.



    Wednesday, June 15, 2011 7:11 PM

All replies

  • Hello,

    Thank you for posting.

    I made a test on my side, we comment primary key in our side after created relative tables in database. But we cannot modify data of these relative tables, add, delete or other operations etc. because the compiler cannot find the primary key in primary table.

    In addition, could you please tell us why would you want to comment the primary key in your code? If you have any specific need, please feel free to descript more detail and let us know.

    Best Regards,

    Larcolais Gong[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, June 20, 2011 5:59 AM
  • Hi, sorry maybe I did not explain.  I'm asking how to do code first mapping to a table without a PK.  There is only a FK... Surely someone in the community can appreciate that it can be a valid 1980's type of thinking but still valid case that has to be mapped.  I really don't want to change the table unless we have to.  Hopefully the EF 4.0 team thought about legacy database design?
    Wednesday, June 29, 2011 3:51 PM