Skip to content

10 Start Database with Sample Data (Database Seed)

M. Fares edited this page Mar 12, 2018 · 2 revisions

You may start your database with sample data such as the list of departments, categories of products, types of emplyees etc.

To seed your database, insert data in /Migrations/Configurations.cs/Seed() methods.

The method AddOrUpdate() is used in case the data already exists, so it will be updated.

You may create methods such as AddDepartments to organize your code.

Seeding the users and roles has to be done through the usermanager and role manager (see admin example).

Clone this wiki locally