How to update models in VS 2019 from database in Entity Framework in ASP.NET Core(如何从 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 中的模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何从 ASP.NET Core 实体框架中的数据库更新 VS 2


基础教程推荐
- MySQL 5.7参照时间戳生成日期列 2022-01-01
- while 在触发器内循环以遍历 sql 中表的所有列 2022-01-01
- 带更新的 sqlite CTE 2022-01-01
- 如何在 CakePHP 3 中实现 INSERT ON DUPLICATE KEY UPDATE aka upsert? 2021-01-01
- CHECKSUM 和 CHECKSUM_AGG:算法是什么? 2021-01-01
- ORA-01830:日期格式图片在转换整个输入字符串之前结束/选择日期查询的总和 2021-01-01
- MySQL根据从其他列分组的值,对两列之间的值进行求和 2022-01-01
- 带有WHERE子句的LAG()函数 2022-01-01
- 使用 VBS 和注册表来确定安装了哪个版本和 32 位 2021-01-01
- 从字符串 TSQL 中获取数字 2021-01-01