尝试使用 WTM来创建项目

尝试使用 WTM来创建项目

进入Model项目中建立一个Hospital的类

image

在DataAccess中的DataContext.cs中增加

public DbSet<Hospital> Hospital { get; set; }

并修改下面的CreatDbContentext()的返回连接

return new DataContext("Data Source=121.5.5.5;User ID=JYDS_LIS;Password=XhiLrZLFTNCEmeZH; Initial Catalog=jyds_lis;", DBTypeEnum.SqlServer);

注意这里的连接,必须要精简,否者后面的升级数据库就会各种报错

Keyword not supported: 'charset'.

Keyword not supported: 'port'.

因为第一次运行已经创建好了数据库,这里修改了Model类中的内容,就要重新更新一下数据库.

Add-Migration electron

Update-Migration

image

这个过程,可能还提示把DataAccess的项目设置为主项目.

看到上面的提示就成功了.

install-package Microsoft.EntityFrameworkCore.Design
add-migration f21
Update-Database
Uninstall-Package Microsoft.EntityFrameworkCore.Design

posted @ 2022-09-09 19:40  忍者叮叮叮  阅读(167)  评论(0编辑  收藏  举报