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必须'; 有 ...
随机推荐
- nginx架构与基础概念
1 Nginx架构 Nginx 高性能,与其架构有关. Nginx架构: nginx运行时,在unix系统中以daemon形式在后台运行,后台进程包含一个master进程和多个worker ...
- hdu1845(a^b的因子和%p)
题目链接:http://poj.org/problem?id=1845 思路: 1.整数唯一分解定理: 任意正整数都有且只有一种方式写出其素因子的乘积表达式. a=(p1^k1)*(p2^k2)*(p ...
- zancun
#include<iostream> #include<cstdio> using namespace std; ; int n; int avai[maxn], need[m ...
- SP7258 SUBLEX - Lexicographical Substring Search
\(\color{#0066ff}{ 题目描述 }\) 给定一个字符串,求排名第k小的串 \(\color{#0066ff}{输入格式}\) 第一行给定主串(len<=90000) 第二行给定询 ...
- log4j配置文件及java调用 每个级别输出到不同的文件
#配置根Logger log4j.rootLogger = DEBUG , RollingFile,CONSOLE #文件大小达到一定尺寸的时候创建一个新的文件 log4j.appender.Roll ...
- BestCoder Round #80 待填坑
Lucky Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submi ...
- DataSet强类型、TableAdapter的使用
简答使用可以看https://www.cnblogs.com/namejr/p/10411920.html中的"先来简单介绍dataset和datatable" DataSet强类 ...
- C3算法之我见
C3算法说到底就是merge算法,看了一些帖子,总结说得莫名其妙,大家也是抄来抄去,我试着用自己的话来把这个东西怎么操作的说清楚.当然了我也要抄一些别人的,但是我会 尽量把我认为别人没有讲清楚的那一部 ...
- npm install 安装包报错
D:\hapi_learn>npm .x.x npm ERR! code ENOSELF npm ERR! Refusing to install package with name " ...
- HDU - 1042-N!(Java)
Given an integer N(0 ≤ N ≤ 10000), your task is to calculate N! Input One N in one line, process to ...