Browse Source

Create a new Database Migration section.

pull/4864/head
Halil İbrahim Kalkan 6 years ago
parent
commit
d3f4a3c928
  1. 16
      docs/en/Tutorials/Part-7.md
  2. BIN
      docs/en/Tutorials/images/bookstore-add-migration-authors.png

16
docs/en/Tutorials/Part-7.md

@ -69,17 +69,31 @@ builder.Entity<Author>(b =>
{
b.ToTable(BookStoreConsts.DbTablePrefix + "Authors",
BookStoreConsts.DbSchema);
b.ConfigureByConvention();
b.Property(x => x.Name)
.IsRequired()
.HasMaxLength(AuthorConsts.MaxNameLength);
b.HasIndex(x => x.Name);
});
````
This is just like done for the `Book` entity before, so no need to explain again.
## Create a new Database Migration
Open the **Package Manager Console** on Visual Studio and ensure that the **Default project** is `Acme.BookStore.EntityFrameworkCore.DbMigrations` in the Package Manager Console, as shown on the picture below. Also, set the `Acme.BookStore.Web` as the startup project (right click it on the solution explorer and click to "Set as Startup Project").
Run the following command to create a new database migration:
![bookstore-add-migration-authors](images/bookstore-add-migration-authors.png)
This will create a new migration class. Then run the `Update-Database` command to create the table on the database.
> See the [Microsoft's documentation](https://docs.microsoft.com/en-us/ef/core/managing-schemas/migrations/) for more about the EF Core database migrations.
{{else if DB=="Mongo"}}
TODO, for MongoDB

BIN
docs/en/Tutorials/images/bookstore-add-migration-authors.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Loading…
Cancel
Save