# EntityFramework.SqlServer

**Kind:** Service

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

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

NuGet package dependency

`EntityFramework.SqlServer` is a NuGet package dependency declared in `Pams.Data.csproj`. It provides the SQL Server provider for Entity Framework in the Pams data layer, allowing repository and data-access code to connect to and query SQL Server databases.

## Diagram

```mermaid
sequenceDiagram
    participant App as Application
    participant Data as Pams.Data
    participant EF as Entity Framework
    participant SQL as SQL Server

    App->>Data: Request data operation
    Data->>EF: Create query or save changes
    EF->>SQL: Execute SQL Server command
    SQL-->>EF: Return results
    EF-->>Data: Materialize entities
    Data-->>App: Return data result
```

## Usage

```ts
// JavaScript clients do not reference EntityFramework.SqlServer directly.
// Call an application endpoint backed by the Pams.Data SQL Server provider.

async function getPatient(patientId: string) {
  const response = await fetch(`/api/patients/${patientId}`);

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

  return response.json();
}

const patient = await getPatient("patient-id");
console.log(patient);
```

## AI Coding Instructions

- Keep `EntityFramework.SqlServer` declared as a package reference in `Pams/Data/Pams.Data/Pams.Data.csproj`.
- Configure SQL Server connections and Entity Framework provider settings in the .NET application configuration, not in JavaScript clients.
- Use Entity Framework query and persistence APIs through the Pams data layer rather than issuing SQL Server commands from higher-level application code.
- Check provider version compatibility with the Entity Framework version referenced by the project before changing package dependencies.

## Used by

2 references from 2 files. Each is a place in this repository where the symbol is actually used — go read one rather than trusting an example.

### Injected or called by (2)

- `Pams.API` — `Pams/API/Pams.API/Pams.API.csproj`:1
- `Pams.Data` — `Pams/Data/Pams.Data/Pams.Data.csproj`:1
