1

I expose some database views in my entity model because there are complex queries which can not be realized by using the standard OData query syntax. I use WCF Data Services for exposing these entities to the 3rd party applications. Basically, there are some flows which change my entities in the EF layer. I realized that the entity representing a database view does not contain the most actual data as it is using a EF cache and is not loading the data from the database. The entities representing database tables are always up-to-date. In order to make sure that an entity representing a databae view contains the most actual data, AFAIK a MergeOptions must be set to NoTracking, then the EF executes the query in the database and forgets about the cached values.

Now my question. Is it possible to use CurrentDataSource available in the service operations together with the MergeOptions to force EF to forget about the cached entities and execute the query everytime in the DB? Or are there any other possibilites for how to define that an EF query is not supposed to use cached entity values, but execute the RAW SQL instead?

Tomas Walek
  • 2,516
  • 2
  • 23
  • 37

0 Answers0