tocoolforscool
tocoolforscool

Reputation: 452

Seeding function for database on ASP.NET Core that DOESN'T use EF

I want to seed my database with test data but it looks as if the DbInitializer class requires a DbContext class or a class derived from DbContext. So far I've learned ASP.NET through the tutorials which use EF. Now I'm moving to a different ORM (Dapper) but I still want to seed my database with test data. I tried googling "Seed database without using EF" and all the results are about using EF code first. Is there a different class or method that I can use for this?

Upvotes: 1

Views: 1269

Answers (1)

Win
Win

Reputation: 62280

Dapper is just a wrapper around ADO.NET. It doesn't know anything about underlying tables, column types and relationships like EF. So, you cannot use DbInitializer for creating tables.

For seed, you could just execute a bunch of insert statements on application start using Dapper.

Upvotes: 5

Related Questions