Effort (C#) - 'Sequence contains no matching element' when seeding data to any of my entities

c# effort entity-framework unit-testing

Accepted Answer

ZZZ_tmp
3
2/7/2018 8:59:16 AM

Popular Answer

Hope this is useful.

Many responses state that you must add.FirstorDefault() However, this mistake also happens when utilising data annotations to create the erroneous attributes in your EF expressions.

When utilising Data Annotations, use caution when adding properties.

Example: I failed to see theTypeName = "string" which ought to have beennvarchar since it is the database's data type.

Take notice of theOrder = n , (starts with 0)

I ran upon this when upgrading a former coworker's source code.

[Display(Name = "Name")]
[MaxLength(4000)]
[Column("Name", Order = 14, TypeName = "string")]
public string Name { get; set; }

then I made changes to my code using

[Display(Name = "Name")]
[MaxLength(4000)]
[Column("Name", Order = 15, TypeName = "nvarchar")]
public string Name { get; set; }

:)



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