--- lang: ja-jp breaks: true --- # 移行の概要 > 移行の概要 > https://learn.microsoft.com/ja-jp/ef/core/managing-schemas/migrations/?tabs=dotnet-core-cli ## 移行前のEntity ```csharp= public class Blog { public int Id { get; set; } public string? Name { get; set; } public override string ToString() { return $"[{Id}][{Name}]"; } } ``` :::info これ以降は、`dotnet ef migrations add InitialCreate`を既に実行している前提。 ::: ## 移行後のEntity `CreatedTimestamp`項目を新しく追加する。 ```csharp= public class Blog { public int Id { get; set; } public string? Name { get; set; } // モデルを発展させる public DateTime? CreatedTimestamp { get; set; } public override string ToString() { return $"[{Id}][{Name}][{CreatedTimestamp}]"; } } ``` ## Entityクラスを変更後、コマンドを実行する。 ```shell= dotnet ef migrations add AddBlogCreatedTimestamp ``` ```shell= dotnet ef database update ``` :::info 「AddBlogCreatedTimestamp」は、コメント。日本語も一応使用できた。 ![](https://hackmd.io/_uploads/HJeXuZeY2.png) ![](https://hackmd.io/_uploads/HywfObgth.png) :::