> For the complete documentation index, see [llms.txt](https://jen-hsuan-hsieh.gitbook.io/asp-net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://jen-hsuan-hsieh.gitbook.io/asp-net/chapter1/1.1.the-complete-asp.net-mvc-5-course/13working-with-data/133code-first-migrations.md).

# 1.3.3.Code-first Migrations

* 1.Enable migration
  * Open tools -> NuGet package Manager ->&#x20;
  * Type in package manager console:

    `enable-migrations`
* 2.Add migration
  * Type in package manager console:

    `add-migration 'InitailModel'`
  * It will generate migration files to \~/Migrations according to models witch implement **IdentityDbContext** or add model to IdentityModels.cs

    ```
    public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
    {
      public DbSet<Customer> Customers { get; set; }
    }
    ```
  * If you want to update migration files, type:

    `add-migration InitailModel -Force`
* 3.Update database
  * Type in package manager console:

    `update-database`
  * Check database and tables from \~/App\_Data
* 4.Check database
  * 1.Open solution explore
  * 2.Show all files
