I created the example project. When I make new migration: dotnet ef migration new Initialize
The migration creates new Question table with 3 columns Id, Title, Description. Columns InsertedAt, UpdatedAt are not inclued into the migration.
When I add missing columns into the database manually...
The EF saves only 3 columns (Id, Title, Description) into the database. Columns InsertedAt, UpdatedAt** are not saved. Triggers Inserting and Updating are called correctly.
The EF loads only 3 columns (Id, Title, Description) from the database. Columns InsertedAt, UpdatedAt are not loaded.
Could you help me where the problem is?
Thank you Myth.
public abstract class Trackable
{
public DateTime InsertedAt { get; private set; }
public DateTime UpdatedAt { get; private set; }
static Trackable()
{
Triggers<Trackable>.Inserting += (entry) => { entry.Entity.InsertedAt = entry.Entity.UpdatedAt = DateTime.UtcNow; };
Triggers<Trackable>.Updating += (entry) => { entry.Entity.UpdatedAt = DateTime.UtcNow; };
}
}
public class Question : Trackable
{
public long Id { get; set; }
public string Title { get; set; }
public string Description { get; set; }
}
public class ApplicationDbContext : DbContextWithTriggers
{
public DbSet<Question> Questions { get; set; }
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
: base(options)
{
}
}
Hello,
I created the example project. When I make new migration: dotnet ef migration new Initialize
Could you help me where the problem is? Thank you Myth.