Entity Framework - Dead Ball Zone

This is a practice project to learn Entity Framework.

Using the 1998 game Dead Ball Zone for inspiration.

.NET commands:

NuGet commands

Install Entity Framework Core NuGet package:

dotnet add package Microsoft.EntityFrameworkCore --version 9.0.3

Creation commands

To list all available templates:

dotnet new -l

New class:

dotnet new class -n MyClass

adding to an existing solution:

dotnet sln add Data/Data.csproj

Entity Framework commands

Create a migration, inside of the Console project, referring to the Data project:

dotnet ef migrations add InitialMigration --startup-project ./ --project ../EntityFrameworkCore.Data

Terms

A database-context is an abstraction of the database structure in code.

  • It lists the models and their database table names.
  • It instantiates a database connection during the runtime of the application.
  • Allows configurations to be made in code.

The migrations provide a version-controlled method to maintain the state of the database.

  • It is possible to track when, and by who changes were made.
  • In the Up method, it is described which changes should be made.
  • in the Down method, it is described which changes should be undone. This allows rollback.
  • There is a history table that is kept by default to track migrations.

Installed NuGet packages

A list of installed NuGet packages in this application.

Note that the Microsoft.EntityFrameworkCore.Tools is used for Powershell commands used in the Package Manager Console for Visual Studio and that Microsoft.EntityFrameworkCore.Design is used for cross-platform command tools.

Console project

Microsoft.EntityFrameworkCore.Tools

  • dotnet add package Microsoft.EntityFrameworkCore.Tools --version 9.0.3

Data project

Microsoft.EntityFrameworkCore

  • dotnet add package Microsoft.EntityFrameworkCore --version 9.0.3

Microsoft.EntityFrameworkCore.Sqlite

  • dotnet add package Microsoft.EntityFrameworkCore.Sqlite --version 9.0.3
Description
This is a practice project to learn Entity Framework.
Readme 211 KiB
Languages
C# 100%