如何从ASP.NET Core中的实体框架中的数据库更新VS 2019中的模型 [英] How to update models in VS 2019 from database in Entity Framework in ASP.NET Core

查看:96
本文介绍了如何从ASP.NET Core中的实体框架中的数据库更新VS 2019中的模型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在VS 2019之前,我创建了一个API项目(首先是数据库),一切工作正常,现在我在数据库中进行了一些更改,例如添加新表和某些属性,并为其他数据库修改数据类型,等等.问题是如何更新模型以匹配SQL中的数据库?

By VS 2019, I created an API project (database first), everything it's working well, now I made some changes in the database like add new tables and some property and modify data type for others and so on.., the question is how to update models to match the database in SQL?

这是我的项目的屏幕截图:

this is a screenshot for my project:

推荐答案

尝试通过具有"Force"参数的Scaffold-DbContext重新创建模型.

Try to recreate your models via Scaffold-DbContext with "Force" param.

Scaffold-DbContext "Data Source=yoursource;Initial Catalog=yourdb;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Model -Force

这篇关于如何从ASP.NET Core中的实体框架中的数据库更新VS 2019中的模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆