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必须'; 有 ...
随机推荐
- C 语言 clock() 函数,例:计算多项式值
C 语言 clock() 函数,例:计算多项式值 /** * clock(): 捕捉从程序开始运行到 clock() 被调用时所耗费的时间. * 这个时间单位是 clock tick, 即" ...
- Build SSH for Development on Windows Subsystem for Linux
It seems that Windows Subsystem for Linux (WSL) is getting much more mature than the time when it fi ...
- Oracle数据控制语言(DCL)
数据控制语言 用来授予或者回收访问数据库中的各种对象,如表 .视图 .索引 等 基本的操作如下: --创建用户 CREATE USER jim IDENTIFIED BY changeit; --给用 ...
- 使用box-shadow 实现水波、音波的效果
用到的工具 animation box-shadow html: <div class="watersource"> </div> css: .waters ...
- Xcode的编辑利器Xvim,如何去掉烦人工具栏和文件路径
最近网上看到了一篇关于Xcode的编辑利器,因为以前做FPGA工作时候在ISE SDK下用过vim作为编辑器,所以深知vim的强大,所以安装Xvim: 在安装之后遇到一些配置问题,因为本来就完美控制, ...
- kuangbin专题十二 HDU1176 免费馅饼 (dp)
免费馅饼 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submis ...
- Codeforces Round #532 (Div. 2)- A(思维)
This morning, Roman woke up and opened the browser with nn opened tabs numbered from 11 to nn. There ...
- Realm数据库的使用
https://github.com/lipanquan/Realm/tree/master
- linux日志--查找过滤
- poj 1001 字符串乘法以及处理精度问题
#include<iostream> #include<cstring> using namespace std; int main() { string r; int n,d ...