1 2 Previous Next 15 Replies Latest reply: Oct 25, 2012 8:06 PM by 932936 RSS

    EF beta - views with no primary key

      When importing views into the entity framework designer, it often gives this error (in the edmx file only; no error is shown in the UI):

      warning 6013: The table/view '[view name]' does not have a primary key defined and no valid primary key could be inferred. This table/view has been excluded. To use the entity, you will need to review your schema, add the correct keys, and uncomment it.

      I don't want to cloud the issue by going into the details of the views in question; there will always be views where no PK can be inferred automatically, for many reasons. And I am quite happy to define the key fields myself after import. The problem is that it can't be imported at all. So my question to the ODP.NET developers is: can you just import it, and leave me to define the PK?

      The workaround I am using is:
      1) define a temp table of the same structure
      2) temporarily recreate the view as "select * from [temp table]"
      3) update the model from database
      3) recreate the proper view

      But it's a pain. I have to remember to do that every time I update the model from the database. If I forget, it wipes the mapping, and I have to redefine it manually, field by field.
        1 2 Previous Next