Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
687 views
in Technique[技术] by (71.8m points)

c# - Sequence contains no matching element - EntityFramework

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...