I have some views that I want to use EF 4.1 to query. These are specific optimized representations that do not have keys to talk about; there will be no deletions, updates, just a good choice.
But EF wants to set the key on the model. Is there a way to tell EF to move on, nothing to worry about?
More details
The main purpose of this is to request a set of views optimized for size, query parameters, and associations. The base tables have their own PC, FK, etc. It is indexed, staticized (what's the word?) And optimized.
I would like to have a class (this is a much smaller and simpler version of what I have):
public MyObject //this is a view { Name{get;set} Age{get;set;} TotalPimples{get;set;} }
and a repository built from EF 4.1 CF where I can just
public List<MyObject> GetPimply(int numberOfPimples) { return db.MyObjects.Where(d=> d.TotalPimples > numberOfPimples).ToList(); }
I could open the key, but what is the real purpose of laying out 2 or 3 columns of the natural key? Will it never be used?
Current solution
It seems that their solution will not be EF CF, I have added a complex key to the model and I will expose it in the model. While it goes “with grain” to what can be expected from a “well-designed” db model, in this case IMHO, it added nothing but logic to the model builder, more bytes along the wire and additional properties per class. They will never be used.
source share