Create the Database Asp.Net Core

Company
  1. Install-Package Microsoft.EntityFrameworkCore (Right click on the project and select Manage Nuget Packages).

2. Select Microsoft.EntityFrameworkCore and click Install.

3. Right click on the project (Add – New Folder). Name the folder Data.

4. Create new class in the folder Entities (Add – Class). Name the class Customer.

5. In the class add the following properties.

6. In the folder Data add the new class (Add – Class). Name the class Datacontext.

7. In the class DataContext add the following properties.

8. Add the connection string to json file: appsettings.json.

9. Install-Package Microsoft.EntityFrameworkCore.SqlServer.

10. Add the database injection in Startup class.

11. Save all changes.

12. Open Package Manager Console.

13. Install-Package Microsoft.EntityFrameworkCore.Tools

14. Run the following commands:

  • update-database
  • add-migration DbCreation
  • update-database

15. Verify that the database was created.

Leave a Reply

Your email address will not be published. Required fields are marked *