Skip to content

dotnetappdev/Sports.api

Repository files navigation

1 Sports.api — point it to your SQL Server instance. Create a blank database called SportsAPI and change the connection string in Sports.api to point to it, including the username, password, and server name. alt text alt text

2 Then do the same for Sports.DataImport. This is how we are going to import the data from the URL. Change the appsettings here as well to point to your SQL Server instance and the same database you created in step 1.

alt text

3 Open the Package Manager Console once your settings have been updated. In Visual Studio, run the following commands. Make sure you are in the correct directory —

You can check by running the pwd command, then cd into:

Sports.Infrastructure

alt text

4 Delete the Migrations folder in Sports.Infrastructure, located at Data\Migrations. Remove the entire folder.

5 Then run the following command in the Package Manager Console:

dotnet ef migrations add firstMigrations  --output-dir Data/Migrations --context ApplicationDbContext

alt text

This will recreate the Migrations folder. If you look at your SQL Server instance, you will see the tables created.

6Now that the migrations are created, update the database by running the following command in the Package Manager Console:

dotnet ef database update  

alt text

7 Once that’s done, you can run the Sports.DataImport project. Let it complete.

This will import the data from the URL into your database.

Once that is done, you can run the Sports.api project and it will be able to access the data. You can then use the endpoints to retrieve the data.

alt text

NB SportId Is used to link the data together. It is not a primary key, but it is used to link the data together.

Due to time constraints Developer Testing was completed unit tests are hard to achieve for loading from a url to ef core.

Swagger is used here or at a different URL because of ports on your machine.

https://localhost:7110/swagger/index.html

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages