EF6 and pre-generated views

c# ef-code-first entity-framework t4


I am using EF code first method in my project. Recently I updated EF version of my project to EF 6 using Package Manager Console.

All of my entities are inherited from a BaseEntity class as a super class :

public abstract class BaseEntity
    public virtual int Id { get; set; }

    States _state;

    public States State { get; set;}

    public enum States

And also I don't add the BaseEntity in my DbContext, the program run without any problem, but since I added pre-generated views to my project using EF6 CodeFirst View Generation T4 Template for C# , when I generate the views there is no problem, but when I run my project, I got following error:

The current model no longer matches the model used to pre-generate the mapping views, as indicated by the ViewsForBaseEntitySets786b989cf4a349108a38357765a23070.MappingHashValue property. Pre-generated mapping views must be either regenerated using the current model or removed if mapping views generated at runtime should be used instead. See http://go.microsoft.com/fwlink/?LinkId=318050 for more information on Entity Framework mapping views.

Does know anyone where is the problem? Or at least what is the way to find the problem?

2/9/2014 4:38:14 PM

Accepted Answer

Most likely you are hitting this bug. The title suggests it was fixed in EF 6.1.0 alpha - can you try this release and confirm? If you still see the error can you create a bug on https://entityframework.codeplex.com/WorkItem/Create? Be sure to attach your model - without the model it will be very hard to fix this bug. Another approach to take is to use a different project of mine - interactive EF view generation. You can find more details here and here. The project is available on NuGet. Finally, is your model really that big that you need to use pre-generated views? View generation has been greatly improved in EF6 (and more improvements are coming in 6.1) so I am curious if you really see a significant improvement in your application start up time when using pre-generated views.

2/10/2014 4:24:02 AM

Related Questions


Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow