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

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).

主站蜘蛛池模板: 佛学| 维西| 阳春市| 华池县| 义马市| 宕昌县| 秀山| 大悟县| 佛坪县| 孝昌县| 宜章县| 织金县| 桂平市| 石家庄市| 建昌县| 德庆县| 岫岩| 大洼县| 安丘市| 安顺市| 澜沧| 阿鲁科尔沁旗| 西安市| 莱州市| 简阳市| 景泰县| 庄浪县| 绵阳市| 乡城县| 高邮市| 宁城县| 元阳县| 宜城市| 准格尔旗| 体育| 蒙山县| 罗江县| 和平区| 全州县| 陇西县| 保定市|