• 关于这个错误的不明原因的解决之道


    如题,在MVC3下,我用的Code first开发模式进行的网站开发,在上下文类中,我这样写了一条语句:

    public MVCApollo365Entities() : base("MVCApollo365Entities") {
            }

            protected override void OnModelCreating(DbModelBuilder modelBuilder)
            {
                throw new UnintentionalCodeFirstException();
            }

    红色部分,见鬼了,硬是导致了错误如下:

    Code generated using the T4 templates for Database First and Model First development may not work correctly if used in Code First mode. To continue using Database First or Model First ensure that the Entity Framework connection string is specified in the config file of executing application. To use these classes, that were generated from Database First or Model First, with Code First add any additional configuration using attributes or the DbModelBuilder API and then remove the code that throws this exception.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.Data.Entity.Infrastructure.UnintentionalCodeFirstException: Code generated using the T4 templates for Database First and Model First development may not work correctly if used in Code First mode. To continue using Database First or Model First ensure that the Entity Framework connection string is specified in the config file of executing application. To use these classes, that were generated from Database First or Model First, with Code First add any additional configuration using attributes or the DbModelBuilder API and then remove the code that throws this exception.

    哥哥,我的哥哥,连续调试都是出这个问题,我搞了2天,天哪,网上那些鸟文章,大师的鸟文章,没有一个有用的,更可恨的是,网上的很多大师都写的是英文,自己连大学英语等级考试4级都没有过的人,怎么看的懂,天哪,对着那个百度翻译左一下右一下,真的想把电脑给砸了的感觉,还是没有解决我的问题,等到我快绝望的时候,知道我怎么搞定的吗?我干脆把上面红色的那个方法给注释掉,然后,改路由给改好了,你说碰到这样的情况是不是想撞墙,这个时候感觉这个鸟电脑为什么不是中国人发明的呢,visual studio为什么不是中国人发明的,为什么不用汉字写的那些鸟文,绝望就在那一瞬间浮现了。

    所以,总结如下,任何东西都不是很难,即使是送嫦娥三号去月球我想也不过如此,最重要的是回归基础知识,基础很重要。区区一个路由的问题,把我困在这2天,耽误多少工作啊,杀死多少脑细胞啊,卸了多少次气啊,走了多少寻求解决办法的道啊。

  • 相关阅读:
    0x00 Java 研习录
    0x00 Linux From Scratch 实战
    第一章:Java编程入门
    陈洋总结
    pthread_detach
    explicit用法
    Java动态加载DLL方法
    ToolHelp32 函数
    android根据子view里面的数量自动排版的一个ViewGroup
    安装CocoaPods学习
  • 原文地址:https://www.cnblogs.com/20m13v08c15/p/3479121.html
Copyright © 2020-2023  润新知