Paritosh
Paritosh

Reputation: 4503

Entity Framework Database First only use certain columns

We are currently working on a application which uses entity framework 6, database first approach. There are a few tables we need to pull in, joining them, but they have many columns which we do not want to pull in. I can delete the columns in the edmx but then they regenerate whenever we update the edmx, is there anyway to avoid this?

Upvotes: 0

Views: 160

Answers (1)

Rahul
Rahul

Reputation: 77934

Well, let it pull all the columns. Still you can select only few columns or the columns you need while displaying or passing as model using a LINQ query Select() method and project to a anonymous type.

Other than that, DB First model UI also gives you facility to import Views and stored procedure. That means, whichever customized data you want you can pull the required SQL to a create view ... statement or create procedure... statement and have it imported using Entity Framework.

Upvotes: 2

Related Questions