unit testing with effort for entity framework 6 with computed values

effort entity-framework entity-framework-6 unit-testing

Question

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.

enter image description here

1
3
5/23/2017 11:45:26 AM

Popular Answer

This issue is fixed with the latest update.

You have to set the global EntityFrameworkEffortManager.UseDefaultForNotNullable flag as true.

0
3/10/2019 3:50:01 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow