Reputation: 433
I've done some research into seeding data for my End to End tests that are dependent on things such as an Admin user to login.
Our API is in EF Core, and I'm having trouble figuring out how to seed data. With EF 6, you can use a Seed method in the config.cs file, which runs after migrations are run, but EF Core does not support this method.
What alternative's are there for EF Core & is there any good documentation or tutorials online I can read? I've done some investigating myself, and many of the tutorials have very complicated ways of creating the seed data, and I'm wondering if there is a more standard way to do this.
Upvotes: 0
Views: 469
Reputation: 163
Use InMemory database provider for testing purpose. MS Docs
For seeding use method with TestInitializeAttribute
or AssemblyInitializeAttribute
(if you're using mstest) where you seed your DB with data.
Article about testing with InMemory provider
Upvotes: 0