Data seeding populates a database with an initial, required, or imported set of records. In a board-game API, it replaces temporary dummy data with records loaded into real database tables, allowing normal retrieval and later CRUD operations. section 5.2.2 section 5.3
A practical CSV seeding workflow consists of these steps:
- Place the CSV file in a project folder and install a package that maps CSV rows to C# objects. section 5.3
- Define a BggRecord POCO, then create a SeedController action dedicated to importing the data. section 5.3
- Configure CsvHelper, open the file with StreamReader, parse records, and map each record to EF Core entities. section 5.3.5
- Skip rows without required identifiers or names and skip records already present in the database. section 5.3.5
- Save the new entities and return counts for imported tables and skipped rows. section 5.3.5
An idempotent seed endpoint
Expose the import action through HTTP PUT, disable response caching, and check existing records before insertion. Repeating the request therefore leaves already imported data unchanged. Keep unrelated initialization tasks separate: board-game data can use /Seed/BoardGameData, while roles and users use /Seed/AuthData. section 5.3.5 section 9.4.2
Use the empty data-array response to verify why seeding is necessary after switching retrieval from dummy data to a database query. section 5.2.2

