Entity Framework and Views

entity-framework firebird views

Question

I want to include a view I've generated in my database into my entity model. However, a warning message notifies me that the TABLE OR VIEW I'm attempting to create doesn't have a primary key when I try to change the entity model with VS 2008.

It seems that a key field is necessary for adding a view to the model. If views aren't allowed to include key fields, at least in Firebird, the DBMRS I'm using, how can I add this view to my model?

Any suggestions for resolving this?

1
21
4/6/2010 9:55:47 PM

Popular Answer

Here's a fantastic response to that: SQL Server with Entity Framework View (see accepted answer: https://stackoverflow.com/a/2715299/53510.)

The PK for views is derived by EF by merging all non-nullable fields. You can force EF to choose the PK you want by manipulating the nullability of view columns using ISNULL and NULLIF.

11
5/23/2017 12:08:27 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow