views:

779

answers:

1

I'm trying to set up an Entity Framework model tied to a bunch of views. When I add a view it wants to make most of the fields into an Entity Key for no apparent reason.

Worse yet, when I try to create an association between two of these views I get an error saying I must specify mapping for ALL key properties... even though I had changed them all to no longer be Entity Keys. I think the underlying table model still has them marked as keys, but I can't change that in the .store object in the designer.

So

1) How do I prevent EF from making every field a primary key?
2) How do I remove the EntityKey=true value from the .store object?
3) Why the hell is this so complicated?

EDIT: Ok, figured out #1. I had to manually edit the xml and delete the keys from the SSDL as well as the CSDL section...

Now if someone can answer 2 and 3 I might be able to get somewhere! ;)

A: 

Note that in the final release of Visual Studio 2010, the designer will automatically sync the key definition from the entity to the key definition of the view - meaning that you won't have to go and edit the SSDL.

Noam Ben-Ami