EF Core Sample Project

Summary: in this tutorial, you will learn how to download an EF Core sample project, create a database and tables, and load data into the database from a CSV file.

First, download the following sample project:

Download EF Core Sample Project

Second, unzip the downloaded file into a directory. It has a Solution that contains a Console App which uses EF Core.

Third, open the solution in Visual Studio.

Fourth, open Package Manager Console (PMC) and run the following command to make a migration:

Add-Migration Initial

Fifth, create the database and tables by executing the following command in the PMC:

Update-Database

By default, the project uses the Local SQL Server database that comes with Visual Studio by default. If you want to use a different database, you can configure the connection string in the appsettings.json file.

The command creates a local HR database with some empty tables.

Finally, load the data from the data.csv file to the database by running the Program.cs file. The program reads data from the data.csv file and populates the tables in the HR database with sample data.

Was this tutorial helpful ?