Geeks With Blogs

News Microsoft MVP

Catch me on FaceBook too!



la familia
Title Of Blog

Just a quick post regarding a common issue and fix...

When attempting to add a view as an entity to your model the EF generator may complain that it is unable to find or infer a primary key on your view. As a result, it will not add it to the model.

The quick fix is to add the following to which ever column you wish to be the primary key within your view:

ISNLL(TableA.ColumnA, -999) myPrimaryKeyColumnName

Adding this will allow the EF generator to infer the primary key and add the view as an entity to your model.

Posted on Tuesday, June 28, 2011 10:13 AM Entity Framework | Back to top


Comments on this post: Entity Framework 4 - Generating Entities based on Views

# re: Entity Framework 4 - Generating Entities based on Views
Requesting Gravatar...
Jake,

Thanks for the great tip...

Wonder why it is not there at MSDN documentation
Bala
Left by Balachander on Nov 02, 2011 5:22 AM

Your comment:
 (will show your gravatar)


Copyright © Jake Rutherford | Powered by: GeeksWithBlogs.net