title: Seed Method in MVC Entity Framework
body: <p>What is the main puspose of <code>seed method</code> in the migration folder of my application? In my <code>Configuration.cs</code> file I got this in my seed method  - </p>
  
  <pre><code>protected override void Seed(TestApplication.DataBaseContext.AppDBContext context)
          {
              //  This method will be called after migrating to the latest version.
  
              //  You can use the DbSet&lt;T&gt;.AddOrUpdate() helper extension method 
              //  to avoid creating duplicate seed data. E.g.
              //
              //    context.People.AddOrUpdate(
              //      p =&gt; p.FullName,
              //      new Person { FullName = "Andrew Peters" },
              //      new Person { FullName = "Brice Lambson" },
              //      new Person { FullName = "Rowan Miller" }
              //    );
              //
              SeedMemebership();
          }
  
          private void SeedMemebership()
          {
              if (!WebSecurity.Initialized)
              {
                  WebSecurity.InitializeDatabaseConnection("DefaultConnection",
                      "UserProfile", "UserId", "UserName", autoCreateTables: true);
              }
              var roles = (SimpleRoleProvider)Roles.Provider;
              var membership = (SimpleMembershipProvider)Membership.Provider;
  
              if (!roles.RoleExists("Administrator"))
              {
                  roles.CreateRole("Administrator");
              }
              if (membership.GetUser("admin", false) == null)
              {
                  membership.CreateUserAndAccount("admin", "password");
              }
              if (!roles.GetRolesForUser("admin").Contains("Administrator"))
              {
                  roles.AddUsersToRoles(new[] { "admin" }, new[] { "Administrator" });
              }
          }
  </code></pre>
  
  <p>As anyone can make out it calls the <code>SeedMembership()</code> which creates a role and a user if it does not exist. When is this <code>seed()</code> called and what does it do? I tried putting a break point on this method but it never really got hit. I tried searching other SO questions for further explainations but it dint help. </p>
  
  <p>Thank You.</p>