I have a customer table in the db that stores the name, address etc, along with some photo, logo and other images.
I am using entity framework and I would like to know how to tackle the situation where I only want to bring back basic data about the customer in certain situations vs the complete data including images.
Should I have two entities, CustomerBasic and CustomerComplete
OR
have one Customer entity and fill it with two separate methods, FillBasic, FillComplete.
Any best practices? i’m new to EF.
It really depends on your repository structure if any – with EF itself you can just use a projection with the properties you do want to a business object instance that represents a “basic customer”, i.e.
Performance becomes more important when you have a collection property (i.e. images in your example) in your entity. In your case you can take advantage of lazy loading to only materialize those properties when and if needed.