MVC数据库问题(更新,添加字段)
1.更新模型之后,在"程序包管理控制器"中输入Update-database,就能自动完成更新
2.对于Update-database之后报错:Automatic migration was not applied because it would result in data loss. Set AutomaticMigrationDataLossAllowed to 'true' on your DbMigrationsConfiguration to allow application of automatic migrations even if they might cause data loss. Alternately, use Update-Database with the '-Force' option, or scaffold an explicit migration.(这种方法是试验出来的,不确定好不好使)
方法:依次输入命令
(1):Update-database -force
(2):Update-database -Verbose
(3):Update-database
3.对于输入Update-database,"无法将“Update-base”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正确,然后再试一次。"
用 : Import-Module 项目地址\packages\EntityFramework.6.1.3\tools\EntityFramework.psd1
4、Automatic migration was not applied because it would result in data loss. Set AutomaticMigrationDataLossAllowed to 'true' on your DbMigrationsConfiguration to allow application of automatic migrations even if they might cause data loss. Alternately, use Update-Database with the '-Force' option, or scaffold an explicit migration.(已经确定)
(1):Add-Migration InitialCreate
(2):Update-database
5、No migrations configuration type was found in the assembly 'DAL'. (In Visual Studio you can use the Enable-Migrations command from Package Manager Console to add a migrations configuration).(没有迁移配置类型。。。)
(1):Enable-Migrations(改true)
(2):Update-database
MVC数据库问题(更新,添加字段)的更多相关文章
- 关于EF更新数据库,更新指定字段的设置
1.关于EF跟新数据库更新指定字段的设置 在EF提交到数据库的时候或许某些字段不想更新.或者自己更新一个模型到数据库去! 1.更新数据不更新一些字段 /// <summary> /// 数 ...
- MySql数据库设计表添加字段
当要添加的字段属于整型,需要设置默认值 或者: alter table fp_user_base add hasPwd tinyint(4) not null default 0;
- Oracle数据库在给表添加字段的sql中用comment报错
原因:不同于mysql,Oracle数据库在添加表字段时不能直接用comment,而是单独写一个sql语句,如下: alter table SYS_USER add SENDMSG_LASTTIME ...
- 往sql数据库表中添加字段
通用式: alter table [表名] add [字段名] 字段属性 default 缺省值 default 是可选参数增加字段: alter table [表名] add 字段名 smallin ...
- 创建ASP.NET Core MVC应用程序(5)-添加查询功能 & 新字段
创建ASP.NET Core MVC应用程序(5)-添加查询功能 & 新字段 添加查询功能 本文将实现通过Name查询用户信息. 首先更新GetAll方法以启用查询: public async ...
- ASP.NET MVC 5 学习教程:数据迁移之添加字段
原文 ASP.NET MVC 5 学习教程:数据迁移之添加字段 起飞网 ASP.NET MVC 5 学习教程目录: 添加控制器 添加视图 修改视图和布局页 控制器传递数据给视图 添加模型 创建连接字符 ...
- paip.解决 数据库mysql增加列 字段很慢添加字段很慢
paip.解决 数据库mysql增加列 字段很慢添加字段很慢 #环境如下: mysql5.6 数据仅仅3w alter table xxx add column yyy int default ...
- varchar2_to_blob,应用向数据库更新LOB字段时的超时问题
将字符串转换为BLOB类型数据,写入服务器. 1,首先利用to_clob函数把varchar2字段转成 clob字段. 2 利用c2b上面函数将clob转成blob. 即: c2b(to_clob( ...
- MySQL之数据库和表的基本操作(建立表、删除表、向表中添加字段)
介绍关于数据库和表的一些基本操作 添加字段.给字段添加注释 ); ) COMMENT '统一社会信用代码录入单位'; ,) 更改字段类型 ,) COMMENT '一头签收,@0或空不用,1必须'; 有 ...
随机推荐
- 网易CentOS yum源
wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
- 跨平台技术iOS与安卓
1.教学资源获取 Flutter的使用教学笔记 2.本地学习笔记
- 787. Cheapest Flights Within K Stops
There are n cities connected by m flights. Each fight starts from city u and arrives at v with a pri ...
- hdu1798(圆的位置关系)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1798 题意:给出两个圆的圆心坐标与半径,求他们相交部分的大小 思路:有三种情况: 1. 两圆相离,ar ...
- 解决dubbo注册zookepper服务IP乱入问题的三种方式
最近做一个项目引入了dubbo+zookepper的分布式服务治理框架.在应用的发布的时候出现一个怪问题.zookepper服务是起在开发服务器192.168.23.180上.本机起应用服务提供者注册 ...
- P3172 [CQOI2015]选数(莫比乌斯反演)
[题目链接] https://www.luogu.org/problemnew/show/P3172 [题解] https://www.luogu.org/blog/user29936/solutio ...
- Django-redis 缓存
存在内存中 Diango-redis redis是一个key-value存储系统.和Memcached类似,它支持存储的value类型相对更多,包括string(字符串).list(链表).set(集 ...
- HDU5952 Counting Cliques计算完全图的个数 巧妙构图+dfs
题目传送门 题目大意:给出n个点,m条无向边,让你计算这幅母图中有几个大小为s的完全图. 完全图的意思是任意一个点都和其他点直接相连,完全图的大小指的就是完全图点的个数. 思路:比较巧妙的构图方式.我 ...
- Java缓存类loadingCache
<dependency> <groupId>com.google.guava</groupId> <artifactId>guava</artif ...
- Linux 防火墙iptables 实例
iptables的基本语法格式 iptables [-t 表名] 命令选项 [链名] [条件匹配] [-j 目标动作或跳转] 说明:表名.链名用于指定iptables命令所操作的表和链,命令选项用于指 ...