MVC中EF代码优先问题
在练习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代码优先问题的更多相关文章
- MVC中使用代码创建数据库(code first +mysql+EF)
1.新建一个mvc项目 2.安装mysql需要的几个文件 EntityFramework.MySql.Data(6.9.12)和MySql.Data.Entity (6.9.12) 这里有几点要注意 ...
- MVC Code First (代码优先)
首先配置web.config <connectionStrings> <add name="BookDbContext" connectionString=&qu ...
- 关于MVC 中EF调用存储过程
Entity Framework 4.3 中使用存储过程 分类:ASP.NET MVC 3, ASP.NET 0 尽管 Entit ...
- ASP.Net MVC 中EF实体的属性取消映射数据库、自定义名称
例如:数据库中一个字段名称为CompanyId 自定义实体数据名称 [Column("CompanyId")] public int Id{ get; set; } 这样就可以使用 ...
- 使用Entity Framework 4进行代码优先开发
[原文地址]Code-First Development with Entity Framework 4 .NET 4随带发布了一个改进版的Entity Framework(EF)- 一个位于Sy ...
- MVC教程--MiniProfiler.EF监控调试MVC和EF的性能
上一篇谈到mvc中ef输出执行sql日志:来谈用mvc开发项目的调试和性能监控.EF框架自动给我生成sql语句,当我们的程序遇到性能问题的时候我们可以用MiniProfiler.EF来监控调试MVC和 ...
- 在快速自定义的NopCommerce中使用实体框架(EF)代码优先迁移
我看到很多nopCommerce论坛的用户问他们如何使用Entity Framework(EF)代码优先迁移来自定义nopCommerce,添加新的字段和entites核心.我实际上在做nopComm ...
- MVC中使用EF(2):实现基本的CRUD功能
MVC中使用EF(2):实现基本的CRUD功能 By Tom Dykstra |July 30, 2013 Translated by litdwg Contoso University示例网站 ...
- 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 ...
随机推荐
- Nginx反向代理、负载均衡、动静分离、缓存、压缩、防盗链、跨域访问
一.反向代理 1.在192.168.189.130机器启动tomcat服务,http://192.168.189.130:8080/ 访问服务正常 2.在192.168.189.131机器配置ngin ...
- SpringCloud笔记一:扫盲
目录 前言 什么是微服务? 微服务的优缺点是什么? 微服务之间是如何通讯的? SpringCloud和Dubbo有哪些区别? SpringCloud和SpringBoot的关系? 什么是服务熔断?什么 ...
- Git 分支(一)简介&创建分支
理解Git暂存区 文件.git/index是一个包含文件索引的目录树,像是一个虚拟的工作区.在这个虚拟工作区的目录树中,记录了文件名和文件的状态信息.以便快速检测文件的变化. ...
- javax.websocket.DeploymentException: Multiple Endpoints may not be deployed to the same path [/websocket/{sid}] : existing endpoint was class com.sanyi.qibaobusiness.framework.webSocket.WebSocketServe
报错: javax.websocket.DeploymentException: Multiple Endpoints may not be deployed to the same path [/w ...
- 拖动DIV
链接:https://www.cnblogs.com/joyco773/p/6519668.html 移动端:div在手机页面上随意拖动 1 <!doctype html> 2 & ...
- Ubuntu18.04问题记录
1. pip install 包时偶然间碰上了如下问题: Could not install packages due to an EnvironmentError: [Errno 13] 权限不够: ...
- Codeforces Round #527 (Div. 3) . F Tree with Maximum Cost
题目链接 题意:给你一棵树,让你找一个顶点iii,使得这个点的∑dis(i,j)∗a[j]\sum dis(i,j)*a[j]∑dis(i,j)∗a[j]最大.dis(i,j)dis(i,j)dis( ...
- UOJ #109「APIO2013」TASKSAUTHOR
貌似是最入门的题答题 刚好我就是入门选手 就这样吧 UOJ #109 题意 太热了不讲了 $ Solution$ 第一个点:$ 105$个数字卡掉$ Floyd$ 直接$101$个点无出边一次询问就好 ...
- L1-Day3
L1-Day31.太阳从西边落下. [我的翻译]The sun falls in the west. [标准答案]The sun sets in the west. [对比分析]落下fall与set的 ...
- Linux centos系统安装后的基本配置,Linux命令
一.centos系统安装后的基本配置 .常用软件安装 yum install -y bash-completion vim lrzsz wget expect net-tools nc nmap tr ...