Skip to content

Latest commit

 

History

History
41 lines (35 loc) · 793 Bytes

File metadata and controls

41 lines (35 loc) · 793 Bytes

Repository Pattern in c# and Entity Framework

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

Run

Step 1

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,
)

Step 2

Intstall dependencies:

dotnet restore

Step 3

Compile and run (from the root path of the project):

dotnet run