That simple. I need to create a View using Code First. I found nothing about this on google nor SO. Is there a way to accomplish this?
I need that view to be created and queried using linq, so it’s not a solution to create it using an script on Database creation, for example:
var results = from c in db.Customer
join v in db.MyView on c.Id equals v.Id
select c;
A work around is also acceptable. I need a way to query entities against non-constant/ non-entities values.
You cannot create views with EF Code First approach. If you want to create view then execute creation sql script in
Seedmethod. But you’ll still not be able to map entity to this view, except hacking model by creating and droping table with same name as your view will have.Some helpful links: