Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Receiving System.Data.Entity.Core.EntityCommandCompilationException when views are out of date. #13

Open
ddivita opened this issue Dec 11, 2019 · 6 comments

Comments

@ddivita
Copy link

ddivita commented Dec 11, 2019

First, we are storing our view cache in the DB.

We ran into an issue where the View cache was out of date and was causing the System.Data.Entity.Core.EntityCommandCompilationException to be thrown.

Inner Exception:
The query view generated for the EntitySet 'Vendors' is not valid. The query parser threw the following error : The argument type 'Edm.String' is not compatible with the property 'IsTraining' of formal type 'Edm.Boolean'.

I ended up clearing the __ViewCache table and restarted the application. When is the view cache updated? Should we be performing any maintenance on the table, regularly?

@moozzyk
Copy link
Owner

moozzyk commented Dec 11, 2019

It would be interesting to understand how you go this error. The way it is supposed to work is that EF allows getting a hash for each model. The base assumptions in this library is that if the model changes the hash will also change. If views don't exist or the hash for the current model is different from the hash of a model that was previously generated the library regenerates views and store with the new hash. From your description it appears that the hashes of two models were the same even though the models were different. Do you by any chance have the old and new views and can share them?
The view cache is updated when the application starts. If you cleared the __ViewCache table and start the application you should see the views stored in the table.

@ddivita
Copy link
Author

ddivita commented Dec 12, 2019

The only model change to that entity was unrelated to the error. The IsTraining was not updated looking at our source code. Also, the change happened on the 12/04/2019 and the View Cache was updated on the 5th. I'll see if I can get a copy of the previous ViewCache data.

@moozzyk
Copy link
Owner

moozzyk commented Dec 12, 2019

I wonder if EF could trigger some kind of optimization based on the change you made. Still my understanding is that any model change should change the hash which should trigger regenerating views. I release a new version of Interactive Views just to add support for .NET Core. There were no code changes. Did you also update EF by any chance?

@ddivita
Copy link
Author

ddivita commented Dec 18, 2019

No. We are in .net 4.x still.

@sathishselvaraj27
Copy link

sathishselvaraj27 commented Jul 11, 2023

@ddivita @moozzyk
can anyone of you say, where this __viewcache table is present.

@moozzyk
Copy link
Owner

moozzyk commented Jul 12, 2023

SqlServerViewCacheFactory takes a connection string to the database where the table would be created. This is explained in the README with an example:

using (var ctx = new MyContext())
{
    InteractiveViews
        .SetViewCacheFactory(
            ctx, 
            new SqlServerViewCacheFactory(ctx.Database.Connection.ConnectionString));
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants