EF6和预先产生的次 [英] EF6 and pre-generated views

查看:497
本文介绍了EF6和预先产生的次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用我的项目EF代码第一种方法。最近我在我的项目的EF版本更新到 EF 6 使用软件包管理器控制台。

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.

我所有的实体继承从 BaseEntity 类作为超类:

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;

    [NotMapped]
    public States State { get; set;}

    public enum States
    {
        Unchanged,
        Added,
        Modified,
        Deleted
    }
    ....  
}

和我也没有添加 BaseEntity 在我的的DbContext ,程序运行没有任何问题,但因为我使用添加到我的项目预先生成的意见的 EF6 CodeFirst视图生成T4模板C#,当我产生该意见是没有问题的,但是当我跑我的项目,我得到了以下错误:

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:

目前的模式不再使用的模型相匹配预先生成的映射图,由ViewsForBaseEntitySets786b989cf4a349108a38357765a23070.MappingHashValue属性所指示的。预先生成的映射视图必须使用当前的模型或者再生,或者在运行时产生的映射的观点应使用删除。请参见 http://go.microsoft.com/fwlink/?LinkId=318050 为在实体框架映射视图的详细信息。

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?

推荐答案

最有可能你打的这个错误。标题表明它是固定在EF 6.1.0阿尔法 - 你可以试试这个版本并确认?如果你仍然看到错误,你可以创建 https://entityframework.codeplex.com/WorkItem/Create错误的?请务必附上您的模型 - 无模型这将是很难修复这个bug。采取另一种方法是用我的一个不同的项目 - 互动EF视图生成。你可以找到更多的细节的这里这里。该项目可在的NuGet 。最后,是你的模型真的那么大,你需要使用预先生成的看法?查看一代有了很大的改善EF6(和更多的改进在6.1来临),所以我很好奇,如果你真的看到你的应用程序中的显著改善使用预先生成视图时的启动时间。

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.

这篇关于EF6和预先产生的次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆