Entity Framework and Views.. Too many keys on the keychain…

I am currently working pretty heavily with the Microsoft Entity Framework for .NET. I just ran into a nice quirk in the Model Wizard for Views.

Well, it seems the model wizard is not able to intelligently determine the primary keys for a view so it resorts to deciding that any NON NULLABLE field must be a primary key. Retarded…yes.

So how to fix this? Well, as long as you don’t mind never using the wizard again you can go in and remove the entity key flag off the conceptual model fields and then delete the key references on the storage model. This all in the XML editor naturally, because of course you can’t do anything useful int the modeler.

Note: Once you fix your keys, if you rerun the Model Wizard to import/refresh tables, you will have the pleasure of hand editing the file again for all your views.

Will this be fixed in 4.0? We will wait and see

Leave a Reply

Your email address will not be published. Required fields are marked *