Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

SOLVED: How to work with InteractiveViews (Entity Framework 6.2)?


I try to use InteractiveViews nuget package to improve first query execution at my code first app.

namespace POC.UnitTests
public class EntityFrameworkViewCachingTests
private Stopwatch _watch;
private FileViewCacheFactory _veiwFactory;
private static string _path;

public void Setup()
_watch = new Stopwatch();
_connectionDictionary = new Dictionary()
{ 1, new SqlConnectionStringBuilder()
UserID = "UserId",
Password = "Password",
InitialCatalog = "MyDatabase",
DataSource = @"MyDb",
ConnectTimeout = 30,
MinPoolSize = 0,
MaxPoolSize = 100,
MultipleActiveResultSets = true,

_path = Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"..\..\..\", "EFCache.xml"));
_veiwFactory = new FileViewCacheFactory(_path);


Start(() =>
using (var ctx = new ThickDbContext(_connectionDictionary[1].ToString()))

Debug.WriteLine($"Work with cache consumed: {_watch.ElapsedMilliseconds} ms.");


public void QueryExecutionPerfomanceTest(int id)
// Arrange.
var sqlConnection = _connectionDictionary[id].ToString();

// Act.

//Create dbContext, work with them and dispose it.
using (var dbContext = new ThickDbContext(sqlConnection))
var result = dbContext.RESOURCES.SingleOrDefault(r => r.RESOURCEID == id);


//Fill dynamic DTO.
_info = new QueryDataDTO
Id = id,
DurationTime = _watch.ElapsedMilliseconds,
Source = typeof(RESOURCE).Name,

// Assert.
Debug.WriteLine($"id: {}. Duration: {_info.DurationTime} ms.");

private void Start(Action a)
// Sync.

I've been expected that pre-generation views will greatly impove perfomance at first query execution, but I get in general the equal results before and after generating EFCache.xml.

Also i read one post (, but actually did not understand: Actually InteractiveViews works with EF 6.2 or not )

Both results (after and before view generation) show:

Work with cache consumed: 7518 ms.
id: 1. Duration: 3007 ms.

Thus, total time: 10.525

Work with cache consumed: 7363 ms.
id: 1. Duration: 1968 ms."

Thus, total time: 9.331

Q: Тhe difference is negligible ( ~ 13%) Where am I wrong with my implementation?

P.S I work with very big dbContext to get the more obvious result (482 Entities).

Posted in S.E.F
via StackOverflow & StackExchange Atomic Web Robots
This Question have been answered

This post first appeared on Stack Solved, please read the originial post: here

Share the post

SOLVED: How to work with InteractiveViews (Entity Framework 6.2)?


Subscribe to Stack Solved

Get updates delivered right to your inbox!

Thank you for your subscription