When is the Seed method called in a EF code first migrations scenario?

entity-framework entity-framework-6

Question

I'm a new project participant, and this class contains the seed data:

 internal sealed class Configuration : DbMigrationsConfiguration<DAL.Context>
    {
        public Configuration()
        {
            AutomaticMigrationsEnabled = true;
        }

Also, the following code to plant the seed:

protected override void Seed(Context context)
    {
        try
        {

I want to know when theSeed termed a method? When a user really doesupdate-database when a user uses an API and neither the user nor the database are present (basically a new user),update-database ?

1
20
6/10/2014 1:19:20 PM

Accepted Answer

The database tables are initialized with some starting data using the seed approach. The seed method will be used each time you execute the migration and update the database. It is primarily utilized during the testing phase, when it is necessary to often reconstruct the database and load sample data into the database tables. Please read through this link, http://blog.oneunicorn.com/2013/05/28/database-initializer-and-migrations-seed-methods/, for more information on coding before continuing.

14
6/10/2014 1:36:24 PM

Popular Answer

ZZZ_tmp


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow