"Sequence contains no matching element" setting HasColumnType("varchar") in EF Mappings using Effort

.net c# effort entity-framework-6

Question

I have the following Entity Framework (v6.1.3) mapping:

public class FileStoreDocumentEntityMapping : EntityTypeConfiguration<FileStoreDocumentEntity>
{
    public FileStoreDocumentEntityMapping()
    {
        Property(x => x.FileStoreDownloadUrl)
            .HasColumnName("FileStoreDetailsUrl")
            .HasColumnType("varchar")
            .HasMaxLength(1000);
        Property(x => x.FileStoreVersion)
            .HasColumnName("FileStoreVersion")
            .HasColumnType("varchar")
            .HasMaxLength(100);
    }
}

Both columns are of data type = "varchar" in my database and sizes are correct: enter image description here

However, some of my unit tests are failing with this error:

"System.InvalidOperationException: Sequence contains no matching element"

I read in a related post that you can get the error above if you pass an invalid type to the HasColumnType method but in my case "varchar" should be valid.

Any ideas what could be wrong?

Here is how those properties are defined in my entity:

    public virtual string FileStoreVersion
    {
        get;
        set;
    }

    public virtual string FileStoreDetailsUrl
    {
        get;
        set;
    }

Here is an example of one test that fails in the first line:

    [TestMethod]
    public void Delete_ReturnsSuccess()
    {
        _context.DistributionListSelectionCriteriaDepartmentEntities.Add(_distributionListSelectionCriteriaDepartmentEntity);

_context in this case is of type MemoryEnterprisePaycorCodeFirstContext:

    private void InitializeTestObjects()
    {
        _context = new MemoryEnterprisePaycorCodeFirstContext();

Which inherits from my public class EnterprisePaycorCodeFirstContext : DbContext

That class is where i'm initializing my entity mappings:

    protected override void OnModelCreating(DbModelBuilder modelBuilder)
    {
        modelBuilder.Configurations.Add(new FileStoreDocumentEntityMapping());

Could this be because I'm using Effort MemoryContext vs a Real DB context?

public class MemoryEnterprisePaycorCodeFirstContext : EnterprisePaycorCodeFirstContext
{
    public MemoryEnterprisePaycorCodeFirstContext()
        : base(DbConnectionFactory.CreateTransient())
    {
        Database.CreateIfNotExists();
    }

Accepted Answer

I figured what it was. Turns out that I was using Effort library which does not support some Column Types as pointed out by @Balah. I used his technique to bypass the entity mapping configuration when coming from my Memory Context: Effort (EF Unit Testing) giving errors



Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why