序列不包含匹配元素 - EntityFramework [英] Sequence contains no matching element - EntityFramework

查看:837
本文介绍了序列不包含匹配元素 - EntityFramework的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用EF 6.1.0并正在创建一个WCF服务。



首先我创建了一个包含我的实体的类库,Mappers和Context用于初始化EF。
我还创建了一个包含上下文实例化的类,并具有以下代码:

  public IQueryable< [实体] GT; GetAll()
{
return context。[Entity] .AsQueryable();
}

另一方面,我在同一个项目中创建了一个WCF服务,在.svc文件中调用函数GetAll(),如下所示:

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

项目正在建设中。我甚至检查cconfiguration,它在正确的DB。然而,据称创建的数据库和表不存在,并且返回中出现错误Sequence contains no matching element。



如果这个是令人困惑的你指点一下WCF服务使用代码第一实体框架的链接。

解决方案

我有一个错误,我得到一个 System.InvalidOperationException 与消息序列不包含匹配的元素,因为我有一个不正确的字符串值被传递到 .HasColumnType()在我的表配置。


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.

解决方案

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.

这篇关于序列不包含匹配元素 - EntityFramework的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆