--- 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」は、コメント。日本語も一応使用できた。   :::
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up