Entities: Adding a Navigation Property between a View and Table

前端 未结 1 1069
闹比i
闹比i 2021-01-24 22:02

As you can seen in the diagram below there is a one-to-many relationship between the ProjectTask and Dependency table.

相关标签:
1条回答
  • 2021-01-24 22:45

    By default, when you add a database view to your model, Entity Framework will assume every single column is part of the primary key. It does the same thing if you add a table without a primary key defined.

    The solution is to manually edit the edmx file with an XML editor and define the primary key yourself. Find the <EntityType> tag for your view (<EntityType Name="MyView">), then there will be a <Key> element. Remove any non-key columns from that element.

    0 讨论(0)
提交回复
热议问题