-
-
Save atrakic/b8cd3225dd8a6f1548e7d90cca9dc921 to your computer and use it in GitHub Desktop.
Example
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
| 1. Install or Update EF Core CLI | |
| dotnet tool install --global dotnet-ef | |
| 2. Update Your DbContext | |
| In your DbContext class, use the IsTemporal method to configure the entity as a temporal table. | |
| using Microsoft.EntityFrameworkCore; | |
| using System; | |
| namespace YourNamespace | |
| { | |
| public class YourDbContext : DbContext | |
| { | |
| public DbSet<Customer> Customers { get; set; } | |
| public DbSet<Order> Orders { get; set; } | |
| public DbSet<Product> Products { get; set; } | |
| protected override void OnModelCreating(ModelBuilder modelBuilder) | |
| { | |
| modelBuilder.Entity<Customer>() | |
| .ToTable("Customers", b => b.IsTemporal()); | |
| modelBuilder.Entity<Product>() | |
| .ToTable("Products", b => b.IsTemporal()); | |
| modelBuilder.Entity<Order>() | |
| .ToTable("Orders", b => b.IsTemporal()); | |
| } | |
| } | |
| } | |
| 3. Create a Migration | |
| dotnet ef migrations add AddTemporalTables | |
| 4. Update Database | |
| dotnet ef database update |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment