本文介紹了如何從 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 中的模型的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!