0

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?

Paritosh
  • 4,243
  • 7
  • 47
  • 80
  • Look at this post: http://stackoverflow.com/questions/22324064/how-to-get-some-columns-of-entity-in-entity-framework – Sunil Jan 21 '16 at 20:55
  • Another link you might find helpful in your situation is table splitting as explained here: https://msdn.microsoft.com/en-us/data/jj715645.aspx and also in this video: https://www.youtube.com/watch?v=hVxvrjoIPRk – Sunil Jan 21 '16 at 20:59

1 Answers1

2

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.

Rahul
  • 76,197
  • 13
  • 71
  • 125
  • 1
    I agree. Either create a static typed model to project onto, or project onto an anonymous type using the `Select` method – Sam Jan 21 '16 at 20:33