You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
DateTime properties with [NotMapped] attribute will still appear in EF Core model.
For example,
[Table("TestEntity")]
public class TestEntity : Entity<int>
{
public int Hour { get; set; }
[NotMapped]
public DateTime MyTime
{
get => DateTime.Today.AddHours(Hour);
set => Hour = value.Hour;
}
[NotMapped]
public int MyHour
{
get => Hour;
set => Hour = value;
}
}
public class MyDbContext : AbpDbContext<MyDbContext>
{
public DbSet<TestEntity> TestEntities { get; set; }
//......
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<TestEntity>().ConfigureByConvention();
} //add breakpoint here, check the model generated
}
MyTime property is involved in model entity type, MyHour is not.
But EF Core add-migration command works correctly, so there is no MyTime column in database,
Invalid column name 'MyTime' exception will be thrown when querying.
ABP version: 6.0.1
DateTime properties with [NotMapped] attribute will still appear in EF Core model.
For example,
MyTime property is involved in model entity type, MyHour is not.
But EF Core add-migration command works correctly, so there is no MyTime column in database,
Invalid column name 'MyTime' exception will be thrown when querying.
I guess this is the issue? In AbpDbContext.cs :
The text was updated successfully, but these errors were encountered: