# EntityFramework

**Kind:** Service

**Source:** `Pams/API/Pams.API/Pams.API.csproj` (line 1)

**Part of:** [Pams](subsystem-pams)

NuGet package dependency

`EntityFramework` is a NuGet package dependency declared by the `Pams.API` project. It provides the legacy Entity Framework data-access runtime used by the API to query and persist application data.

## Diagram

```mermaid
sequenceDiagram
    participant API as Pams.API
    participant EF as EntityFramework
    participant DB as Database

    API->>EF: Create data context
    EF->>DB: Query or save entities
    DB-->>EF: Return data or result
    EF-->>API: Materialize entities or report status
```

## Usage

```ts
// Entity Framework is consumed by the Pams.API .NET project.
// JavaScript clients call API endpoints that use Entity Framework internally.

const response = await fetch("/api/patients/42");

if (!response.ok) {
  throw new Error("Unable to load patient data");
}

const patient = await response.json();
console.log(patient);
```

## AI Coding Instructions

- Keep `EntityFramework` package references in `Pams.API.csproj` aligned with the API's existing .NET target and dependency format.
- Use the existing Entity Framework data context and entity mappings rather than creating parallel database access code.
- Treat Entity Framework as a server-side dependency; browser TypeScript and JavaScript should access data through API endpoints.
- Check query behavior, entity tracking, and database migrations before changing persistence-related code.
