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

查看:50
本文介绍了如何从 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天全站免登陆