Click here to Skip to main content
12,395,645 members (81,275 online)
Rate this:
Please Sign up or sign in to vote.
See more: EF5.0
how to create view in entity framework(ef)
Posted 8-Mar-13 22:01pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

You need to create Views using SQL query. Post that use it with EF.

Refer: How to Use SQL Server Views with the Entity Framework[^]
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Do you really need views? With LINQ to Entities[^] you can write queries in managed code on top of the entity sets themselves (tables on the other side). The query will be transformed to actual sql query statements only when it is enumerated (this is called deferred execution). And as views are evaluated at runtime too (there is a little preprocessing, but not much) - in general you won't gain a lot. So, although you can use the database side views in your EF model (as Sandeep Mewara pointed out), you have to consider if you really need them.
Think like this: in the traditional development, the lot of the business logic is put on dbms side (views and stored procedures are in general such things), so the BL is split between two or more tires. The EF philosophy is treating the database more like a simple datastore, and is pushing the developer to forge the BL above the data access layer (with the application level entities in mind) - and not split or even below DAL.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.160721.1 | Last Updated 9 Mar 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100