Performing seed data to database from JSON using reflection

source: https://www.red-gate.com/simple-talk/blogs/performing-seed-data-to-database-from-json-using-reflection/?ref=sudhakaryblog.wordpress.com

We can work with two approaches in Asp.Net MVC i.e., DB first approach and Code first approach. Apart from that, we can also work with different ORM models such as Entity framework, NHibernate, etc.

In the code first approach, database create with the migration is simple and easy task to add, update, and delete the data. It helps seed database simply, just add the properties and call the Savechanges method.

We can initialize the code first generated database with the values from JSON using data access layer and reflection. By the way, JSON is considered as the best data format as it gives clean and clear data result. We can apply other formats to the same approach but JSON is used for the ease and the availability of the large and optimal JSON.NET library from Newtonsoft.

Read more ..

Leave a comment