Last active
January 14, 2026 20:34
-
-
Save ssougnez/4dada56d444fdd629710c342deb257ca to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class V1_0_0_InitialSetup: BaseMigration | |
| { | |
| private readonly AppDbContext _db; | |
| private readonly ILogger < V1_0_0_InitialSetup > _logger; | |
| public V1_0_0_InitialSetup(AppDbContext db, ILogger < V1_0_0_InitialSetup > logger) | |
| { | |
| _db = db; | |
| _logger = logger; | |
| } | |
| public override Version Version => new(1, 0, 0); | |
| public override async Task UpAsync() | |
| { | |
| if (FirstTime) | |
| { | |
| _logger.LogInformation("First run! Setting up initial data…"); | |
| _db.Products.AddRange(new Product | |
| { | |
| Name = "Starter Kit", Price = 49.99 m | |
| }, new Product | |
| { | |
| Name = "Pro Bundle", Price = 149.99 m | |
| }); | |
| await _db.SaveChangesAsync(); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment