# Domain Original Names Prompts

> **Standalone prompt for applying `[Table]` and `[Column]` EF Core annotations to domain models.**\
> Use this when the user wants to map FlexBase domain models back to their original database table and column names — enabling EF Core migrations to generate the correct schema.
>
> **This is separate from the main implementation completion workflow** — it can be run independently on any FlexBase domain model project that has extraction JSON with `originalName` / `sourceTable` metadata.

## When to Use

* **Legacy migrations** — keeping the original database schema so existing data doesn't require restructuring
* **Brownfield projects** — new FlexBase API layer on top of an existing database
* **Database-first scenarios** — FlexBase domain models must match an existing schema exactly
* **Post-implementation** — can be applied at any time after domain models are generated

## How to Use

Copy-paste any prompt below into your AI agent chat:

**Apply all original names:**

```
Apply original database names to the domain models
```

**Explicit Table/Column request:**

```
Add [Table] and [Column] attributes from the extraction JSON
```

**Legacy schema mapping:**

```
Map domain models to their legacy database schema
```

**EF Core annotation shorthand:**

```
Add EF Core annotations for the original table and column names
```

***

## What It Does

The agent reads the extraction JSON (`*_DomainServices.json`) and applies:

1. **`[Table("name", Schema = "schema")]`** to each domain model class based on `metadata.sourceTable`
2. **`[Column("originalName")]`** to each property where the original column name differs from the property name
3. **FK type fixes** — ensures all foreign key properties are `string` type (not int/Guid)
4. **C# keyword handling** — properties renamed to avoid C# keywords get `[Column]` to preserve the original name
5. **Build verification** — 0 errors after all annotations applied

**Prerequisites:** Domain model `.cs` files must exist (generated by FlexBase Studio) and extraction JSON must contain `originalName` / `sourceTable` metadata.

***

## Related

* **Full implementation completion:** [Implementation Completion](/flexbase-mcp-ai-prompts/implementation-completion-prompts.md)
* **Legacy migration extraction:** [Legacy Migration → Markdown](/flexbase-mcp-ai-prompts/legacy-migration-prompts-md-file.md)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.flexbase.in/flexbase-mcp-ai-prompts/domain-original-names-prompts.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
