Using effort EF6 with code first does not populate computed values. I have a datetime field (FechaCreacion) that is computed. How can I emulate it in Effort, so It is populated with DateTime.Now after savingChanges() ?
This post Using Effort (EF Testing Tool) with Computed Column is DB First instead of Code First as my example, but seems unanswered too.
EffortConnection connection = (EffortConnection)DbConnectionFactory.CreateTransient();
using (var c = new ControlConfigContext(connection))
{
c.Database.CreateIfNotExists();
CambioRepositoryTestLoadData.Load(c);
string direccionMac = "FFFF";
var repo = new CambioRepository(c);
var primerConcesionarioTerminal = repo.GetPrimerConcesionarioTerminal(direccionMac);
Assert.AreEqual("terminal1", primerConcesionarioTerminal.Terminal);
}
This value is computed in SQLServer as GetDate()
this.Property(t => t.FechaCreacion).HasColumnName("FechaCreacion").HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed);
In sql server works well, but when using Effort in unit testing, the field gets empty date value.
This would seem like an issue with Effort. I have opened an issue on their github site: https://github.com/tamasflamich/effort/issues/62
This issue is fixed with the latest update.
You have to set the global EntityFrameworkEffortManager.UseDefaultForNotNullable
flag as true.
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.