官术网_书友最值得收藏!

Reverse engineering the database

Reverse engineering can be performed on the NuGet Package Manager console. We have already seen how to open it, so just execute the following command to scaffold the context and models files:

    Scaffold-DbContext "Server 
(localdb)\mssqllocaldb;Database=MasteringEFCoreDbFirst;
Trusted_Connection=True;"
Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models

Sometimes we might get errors stating that The package could not be located. The workaround would be opening the project in a separate solution. If we get an Unable to open the database error, then providing access in the SQL Management Studio (connecting the locals from the studio) would resolve the issue. SQL Server Management Studio (SSMS) is a free version and can be downloaded from https://docs.microsoft.com/en-us/sql/ssms/download-sql-server-management-studio-ssms.

Please refer to the following screenshot:

The scaffolding process generates database context files and corresponding data models (in our case, three files in total).

主站蜘蛛池模板: 兰考县| 兴和县| 依安县| 洱源县| 介休市| 汉阴县| 轮台县| 土默特右旗| 满洲里市| 西平县| 白水县| 高碑店市| 准格尔旗| 博客| 大洼县| 治多县| 化德县| 南平市| 正宁县| 沧源| 抚宁县| 巨野县| 泸定县| 南充市| 华阴市| 平昌县| 乌兰县| 荆门市| 陆丰市| 谷城县| 离岛区| 涪陵区| 潜山县| 松原市| 东山县| 天柱县| 富川| 洮南市| 普兰县| 余姚市| 贡嘎县|