Importing JSON Files Into A C# Project
As part of this fun side project I’ve been working on, I’ve been playing around with data that comes in the form of JSON data files. What I want to do is use these data files to seed the data in my database. So here’s a quick one for anyone looking to import JSON data into a running C# application.
I showed in a previous post how I set up my Aspire project to have a separate data migration project to handle the DbContext, schema migrations, and seeding for my Postgres database. While some of the basic seeding is hardcoded into C# classes, most of the data will be coming from various JSON files filled with the data. Let’s walk through how I set up the loading of those files into my database.