This is an example of Repository Pattern using Entity Framework
File structure (the most relevant):
- models
- repositories
- IRepository
- IMyRepository
- Repository
- MyRepository
- MyContext.cs
- MyContextFactory.cs
- UnitOfWork.cs
To run this example, you must have a database (remember to adapt the connection string from the file global.json) and a table with the follow structure:
create table treatment
(
treatmentid int identity primary key,
treatmenttext varchar(100),
-- description of the treatment
price int,
)
Intstall dependencies:
dotnet restore
Compile and run (from the root path of the project):
dotnet run