Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sequence contains no matching element - EntityFramework

Tags:

I'm using EF 6.1.0 and was creating a WCF Service.

First I created a Class Library containing my entities, Mappers and Context for initializing EF. I've also created a class containing an instantiation of the context and have this code:

public IQueryable<[Entity]> GetAll() {     return context.[Entity].AsQueryable(); } 

On the otherhand, I've created a WCF Service on the same project and Calls the function GetAll() in the.svc file like this:

public List<[Entity]> GetList() {     [iObject] repository = new [Object](new Context());     return repository.GetAll().ToList(); } 

The project is building. I even check the cconfiguration and it is in the right DB. However, database and tables which is supposedly created doesn't exist and an error "Sequence contains no matching element" shows up in the return.

If this one is confusing can you point me some link of WCF Services using Code First Entity Framework.

like image 304
choopau Avatar asked Apr 10 '14 08:04

choopau


1 Answers

I had a bug where I got a System.InvalidOperationException with the message Sequence contains no matching element because I had an incorrect string value being passed to .HasColumnType() in my table configuration.

like image 80
Ceisc Avatar answered Oct 10 '22 00:10

Ceisc