Convert Database first into Code first in the Abp Framework

Preface: Abp suite is known as a tool to generate Code first; however, we also want to aply this tool for Database first, so what should we do?

Use for Oracle database.

Download source: https://github.com/ngotruongblog/Generator

Step 0: Download source

Download source at : https://github.com/ngotruongblog/Generator

Step 1: Install EF Core Power Tool for visual studio

image 

Step 2: Right-click in Generater project, choose Reverse Engineer

image 

Step 3: Click the Add Connection icon in Server Explorer

image 

Choose Database Connection -> Choose table/view to generate

image 

image 

Step 4: Install oracle.entityframeworkcore nuget and delete DataContext.cs file

image 

Step 5: Create file json

image 

In which,

  1. _nameSpaceModels: namespace name of prior created entity
    image 
  2. _pathOutput: where contains the json files
  3. _nameProject: module name

Step 6: Copy json files into .suite\entities\ folder in the Abp project

image 

Then, refresh Abp Suite tool and generate code.
image 

Step 7: After generating code from Abp Suite, we need to edit xxxDbContextModelCreatingExtensions.cs so that the colume name could be fit with database

image