# ovidiu00/updateexistingentity architecture

> Architecture diagram of the GitHub repository ovidiu00/updateexistingentity, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ovidiu00/updateexistingentity
- Repository: https://github.com/ovidiu00/updateexistingentity

## Overview

##### Main Components

a) Core Components:
- UpdateIfModified Generic Service
- Entity Framework Context Layer
- Database Layer
- Domain Models Layer

b) Flow Components:
- External Data Source (Excel/API)
- Data Transformation Layer
- Change Detection System
- SQL Generation Layer

**[External Data Source]**
- ↓
**[Data Transformation Layer]**
- ↓
**[UpdateIfModified Service] ←→ [Domain Models]**
- ↓                         ↑
**[EF Core Context] ←→ [Change Detection System]**
- ↓
**[SQL Generation Layer]**
- ↓
**[Database]**

##### Component Details

For each component, include these specific details:

a) UpdateIfModified Service:
- Generic type parameter <T>
- Property comparison logic
- Change tracking integration
- Excluded navigation properties handling

b) Domain Models:
- Entity classes (Employee, Department)
- Property definitions
- Relationship mappings

c) EF Core Context:
- DbContext configuration
- Entity configurations
- Change tracking settings

##### Key Interactions to Highlight

- Comparison flow between existing and modified entities
- Selective property update process
- Demonstrate the SQL generation optimization
- Change tracking integration

##### Technical Details

Annotations for:
- .NET 5.0 runtime
- Entity Framework Core version
- SQL Server connection
- Generic type constraints
- Property exclusion patterns

##### Implementation Notes

Callouts explaining:
- Disconnected scenario handling
- Performance optimization approach
- Navigation property handling
- Change detection strategy

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph External
        EDS[External Data Source]:::external
    end

    subgraph Processing
        DTL[Data Transformation Layer]:::utility
        CDS[Change Detection System]:::utility
        SQL[SQL Generation Layer]:::database
    end

    subgraph Core
        UIM[UpdateIfModified Service]:::core
        DM[Domain Models]:::models
        EFC[EF Core Context]:::database
    end

    subgraph Database
        DB[(Database)]:::database
    end

    %% Connections
    EDS --> DTL
    DTL --> UIM
    UIM <--> DM
    UIM --> EFC
    EFC <--> CDS
    EFC --> SQL
    SQL --> DB

    %% Subcomponents of Domain Models
    DM --> EMP[Employee Model]:::models
    DM --> DEP[Department Model]:::models
    DM --> SEX[Sex Enumeration]:::models

    %% Click Events
    click DM "https://github.com/Ovidiu00/UpdateExistingEntity/tree/main/UpdateObjectEF/Models"
    click EMP "https://github.com/Ovidiu00/UpdateExistingEntity/blob/main/UpdateObjectEF/Models/Employee.cs"
    click DEP "https://github.com/Ovidiu00/UpdateExistingEntity/blob/main/UpdateObjectEF/Models/Department.cs"
    click SEX "https://github.com/Ovidiu00/UpdateExistingEntity/blob/main/UpdateObjectEF/Models/Sex.cs"
    click EFC "https://github.com/Ovidiu00/UpdateExistingEntity/blob/main/UpdateObjectEF/Models/DemoDBContext.cs"
    click DTL "https://github.com/Ovidiu00/UpdateExistingEntity/blob/main/UpdateObjectEF/Models/UtilityClass.cs"
    click UIM "https://github.com/Ovidiu00/UpdateExistingEntity/blob/main/UnitTest/UpdateIfModifiedTests.cs"

    %% Styles
    classDef external fill:#90EE90,stroke:#333,stroke-width:2px
    classDef core fill:#87CEEB,stroke:#333,stroke-width:2px
    classDef models fill:#FFE4B5,stroke:#333,stroke-width:2px
    classDef database fill:#FFD700,stroke:#333,stroke-width:2px
    classDef utility fill:#D3D3D3,stroke:#333,stroke-width:2px

    %% Legend
    subgraph Legend
        L1[External Components]:::external
        L2[Core Components]:::core
        L3[Model Components]:::models
        L4[Database Components]:::database
        L5[Utility Components]:::utility
    end
```
