在练习Mvc项目时,提示如下数据库错误:

The model backing the 'EFDbContext' context has changed since the database was created. Consider using Code First Migrations to update the database (http://go.microsoft.com/fwlink/?LinkId=238269).

按上述链接要求,在程序包管理控制台执行:Enable-Migrations 后,

生成对应DAL目录内生成 Mirgrations新目录,

再执行 Update-Database, 提示

Specify the '-Verbose' flag to view the SQL statements being applied to the target database.
No pending explicit migrations.
Unable to update database to match the current model because there are pending changes and automatic migration is disabled. Either write the pending model changes to a code-based migration or enable automatic migration. Set DbMigrationsConfiguration.AutomaticMigrationsEnabled to true to enable automatic migration.
You can use the Add-Migration command to write the pending model changes to a code-based migration.

项目仍无法连接数据库,

后直接清除数据库内的 [__MigrationHistory]表数据,

问题成功解决。

MVC中EF代码优先问题的更多相关文章

  1. MVC中使用代码创建数据库(code first +mysql+EF)

    1.新建一个mvc项目 2.安装mysql需要的几个文件 EntityFramework.MySql.Data(6.9.12)和MySql.Data.Entity (6.9.12) 这里有几点要注意 ...

  2. MVC Code First (代码优先)

    首先配置web.config <connectionStrings> <add name="BookDbContext" connectionString=&qu ...

  3. 关于MVC 中EF调用存储过程

    Entity Framework 4.3 中使用存储过程 分类:ASP.NET MVC 3, ASP.NET                  0                   尽管 Entit ...

  4. ASP.Net MVC 中EF实体的属性取消映射数据库、自定义名称

    例如:数据库中一个字段名称为CompanyId 自定义实体数据名称 [Column("CompanyId")] public int Id{ get; set; } 这样就可以使用 ...

  5. 使用Entity Framework 4进行代码优先开发

    [原文地址]Code-First Development with Entity Framework 4   .NET 4随带发布了一个改进版的Entity Framework(EF)- 一个位于Sy ...

  6. MVC教程--MiniProfiler.EF监控调试MVC和EF的性能

    上一篇谈到mvc中ef输出执行sql日志:来谈用mvc开发项目的调试和性能监控.EF框架自动给我生成sql语句,当我们的程序遇到性能问题的时候我们可以用MiniProfiler.EF来监控调试MVC和 ...

  7. 在快速自定义的NopCommerce中使用实体框架(EF)代码优先迁移

    我看到很多nopCommerce论坛的用户问他们如何使用Entity Framework(EF)代码优先迁移来自定义nopCommerce,添加新的字段和entites核心.我实际上在做nopComm ...

  8. MVC中使用EF(2):实现基本的CRUD功能

    MVC中使用EF(2):实现基本的CRUD功能 By  Tom Dykstra |July 30, 2013 Translated by litdwg   Contoso University示例网站 ...

  9. MVC中使用EF(1):为ASP.NET MVC程序创建Entity Framework数据模型

    为ASP.NET MVC程序创建Entity Framework数据模型 (1 of 10) By  Tom Dykstra |July 30, 2013 Translated by litdwg   ...

随机推荐

  1. OS + CentOS / http_proxy / https_proxy / dalishangwang / repo

    s OS + Linux RedHat / redhat7 / redhat 7 / redhat 6 / redhat 5 https://lindows.iteye.com/blog/456637 ...

  2. “字节跳动-文远知行杯”广东工业大学第十四届程序设计竞赛 1010 Count

    思路:矩阵快速幂.推一下初始矩阵就好了 #include<bits/stdc++.h> #define LL long long #define fi first #define se s ...

  3. Hough transform(霍夫变换)

    主要内容: 1.Hough变换的算法思想 2.直线检测 3.圆.椭圆检测 4.程序实现 一.Hough变换简介 Hough变换是图像处理中从图像中识别几何形状的基本方法之一.Hough变换的基本原理在 ...

  4. 引用变量&和指针*的区别

    &在C/C++中做右值时,为取地址运算符,来指示变量的地址.C++给&符号赋予了另外一个含义,将其用来声明引用. 引用变量的作用: 1.别名 int b = 0; int& a ...

  5. org.hibernate.boot.MappingNotFoundException: Mapping (RESOURCE) not found :

    可能原因: hibernate映射文件hibernate.cfg.xml中mapping中resource写错了文件名或者路径

  6. 往服务器部署thinkphp5代码时要注意 pathinfo的问题

    往服务器部署thinkphp5代码时要注意 pathinfo的问题 如果nginx没有做任何设置 要使用?s=/的方式访问地址 只需要修改3个地方就可以了,亲测成功,看代码有注解 location ~ ...

  7. sed 使用行号与关键字匹配限定行范围

    1.打印匹配数字4 到最后一行 [111 sed]$ cat input [111 sed]$ sed -n '/4/,$p' input

  8. SSH阅读笔记

    1.SSH单阶人脸段检测器,在不同层检测不同scale的人脸,而不是使用mtcnn中金字塔的方式,从而实现加速. 2.SSH的整体结构,3个module的stride分别为8,16,32,使用不同的感 ...

  9. Java的家庭记账本程序(I)

    日期:2019.2.26 博客期:037 星期二 Part 1: 今天使用新的"radio"标签,将搜索方式的选则内容更改了,如下图,不过,研究了很久的数据库连接也还是没有成功!嗯 ...

  10. VMware安装CentOS7系统