默认ASP.NET Core 3.x项目和Identity选项出现nvarchar和nvarchar(max)错误
Copyright Notice: This article is an original work licensed under the CC 4.0 BY-NC-ND license.
If you wish to repost this article, please include the original source link and this copyright notice.
Source link: https://v2know.com/article/478
报错日志:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'max) NULL, CONSTRAINT `PK_AspNetRoles` PRIMARY KEY (`Id`) )' at line 5
场景描述:
尝试在.net core 3.1 mvc项目下使用mysql数据库,在add-migrations的时候,报错了。
参考来源:
https://github.com/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql/issues/865
简述:
出现这个问题,是因为asp.net core默认是认为你用的sql server。
解决方案:
直接删除Migrations整个文件夹即可。
我的话,是删除了Migrations文件夹,然后在程序包管理控制台输入Add-Migration CreateIdentitySchema,回车;
接着再输入Update-Database,回车,结束。
顺便一提,我的Pomelo.EntityFrameworkCore是3.1.0,我还顺便安装了Pomelo.EntityFrameworkCore.MySql.Design,这是默认用来Code first的nuget包。
This article was last edited at 2020-10-16 05:50:38