但是大概会报错,提示EntityFramework的步伐包未安装
Your target project 'ShangShangQian' doesn't reference EntityFramework. This package is required for the Entity Framework Core Tools to work. Ensure your target project is correct, install the package, and try again.
NuGet安装下
安装完毕,再实验Add-Migration firstMigration
No migrations configuration type was found in the assembly 'ShangShangQian'. (In Visual Studio you can use the Enable-Migrations command from Package Manager Console to add a migrations configuration).
在步伐集“ShangShangQian”中找不到迁徙配置范例。(在Visual Studio中,可以利用Package Manager控制台中的“启用迁徙”命令添加迁徙配置)。
Checking if the context targets an existing database...
System.ArgumentException: The type 'DataBaseContext' does not inherit from DbContext. The DbMigrationsConfiguration.ContextType property must be set to a type that inherits from DbContext
The type 'DataBaseContext' does not inherit from DbContext. The DbMigrationsConfiguration.ContextType property must be set to a type that inherits from DbContext.
正在检查上下文是否以现有数据库为目的。。。
系统ArgumentException:范例“DataBaseContext”不是从DbContext继承的。DbMigrationsConfiguration。ContextType属性必须设置为从DbContext继承的范例。
Both Entity Framework Core and Entity Framework 6 are installed. The Entity Framework Core tools are running. Use 'EntityFramework6\Enable-Migrations' for Entity Framework 6.
Enable-Migrations is obsolete. Use Add-Migration to start using Migrations.
实体框架核心和实体框架6都已安装。实体框架核心工具正在运行。对实体框架6利用“EntityFramework6\启用迁徙”。
“启用迁徙”已过时。利用“添加迁徙”开始利用迁徙。
=======》去你姥姥的,坑我,这不回到了出发点《======= Add-Migration firstMigration
死马当活马医吧,实验试试
再跑下更新命令?
update-database
复制代码
表模型变更,实验这俩行,去测试下 把表和字段增长·删除·试试,哦 报错了……
Failed executing DbCommand (0ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
CREATE TABLE "Chats" (
"ChatID" INTEGER NOT NULL CONSTRAINT "K_Chats" PRIMARY KEY AUTOINCREMENT,
"FromID" INTEGER NOT NULL,
"ToID" INTEGER NOT NULL,
"Message" TEXT NOT NULL,
"Type" INTEGER NOT NULL,
"IsRead" INTEGER NOT NULL,
"SendTime" TEXT NOT NULL,
"ReadTime" TEXT NOT NULL,
"IsPushFrom" INTEGER NOT NULL,
"IsPushTo" INTEGER NOT NULL
);
SQLite Error 1: 'table "Chats" already exists'.