---
title: "How to apply a migration to update the database schema in Entity Framework Core?"  
description: "How to apply a migration to update the database schema in Entity Framework Core?"  
author: "Utpal Vishwas"  
published: 2023-10-20  
updated: 2023-10-22  
canonical: https://www.mindstick.com/forum/160254/how-to-apply-a-migration-to-update-the-database-schema-in-entity-framework-core  
category: ".net core"  
tags: ["asp.net core", ".net core", "database migration"]  
reading_time: 2 minutes  

---

# How to apply a migration to update the database schema in Entity Framework Core?

How to [apply](https://www.mindstick.com/articles/13148/discover-to-apply-make-up-like-a-professional-supermodel) a [migration](https://www.mindstick.com/articles/23202/magento-1-to-magento-2-migration-the-ultimate-guide-updated-2018) to [update](https://www.mindstick.com/forum/156353/what-is-hummingbird-update) the [database schema](https://www.mindstick.com/articles/337228/a-guide-for-designing-a-database-schema-for-an-application) in [Entity Framework](https://www.mindstick.com/articles/1566/crud-operations-using-entity-framework-code-first-approach) Core?

## Replies

### Reply by Aryan Kumar

To apply a migration and update the [database](https://www.mindstick.com/articles/12226/use-of-database-in-sencha-extjs-and-insert-record-from-user-form-using-ajax) [schema](https://www.mindstick.com/articles/1844/how-schema-markup-useful-in-serp) in [Entity](https://www.mindstick.com/forum/160562/database-connectivity-using-entity-framework-database-first-approach) [Framework](https://www.mindstick.com/forum/34615/software-framework-vs-library) Core, follow these steps:

## 1. Create or Modify Your Model:

- First, make the necessary changes to your data model. This could involve adding or modifying entities, properties, relationships, or any other changes that impact the database schema.

## 2. Generate a Migration:

Open a command prompt, terminal, or Package Manager Console in Visual Studio. Navigate to your project's root directory where your DbContext is defined.

Run the following command to create a new migration. Replace **[DescriptiveMigrationName]** with a name that describes the changes made to your model:

```plaintext
dotnet ef migrations add [DescriptiveMigrationName]
```

This command generates a new migration file in your project's "Migrations" folder, which contains the instructions to update the database schema.

## 3. Apply the Migration:

- Run the following command to apply the migration and update the database schema:

```plaintext
dotnet ef database update
```

This command executes the SQL statements generated in the migration to update the database schema according to the changes in your model.

## 4. Verify the Database:

- After applying the migration, you can verify that the changes have been successfully applied to the database by inspecting the database schema.

By following these steps, you can create a migration and use it to update the database schema in Entity Framework Core. Migrations help you manage and evolve the database schema alongside changes in your application's data model.


---

Original Source: https://www.mindstick.com/forum/160254/how-to-apply-a-migration-to-update-the-database-schema-in-entity-framework-core

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
