I've got a class
public class MyEntity
{
public IDateTimeProvider DateTimeProvider { get; }
public MyEntity(IDateTimeProvider dateTimeProvider)
{
DateTimeProvider = dateTimeProvider;
}
protected MyEntity()
{
}
}
When I map this to the DbContext
, I want it to ignore this column (as it's not a primitive type). When it loads from the database, I want it to populate this column with an instance of DateTimeProvider
.
Does anyone know how to do this?
I want to say something like:
modelBuilder
.Entity<MyEntity>()
.Property(x => DateTimeProvider)
.Ignore()
.OnLoadInject(new DateTimeProvider());
If you do not want to create a column in the database, you can use the [NotMapped]
annotation on the property. More info:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.