开发者

Moving model to different project causes error: Object mapping could not be found for Type with identity

开发者 https://www.devze.com 2023-03-19 16:25 出处:网络
I have a problem with EF. It started when I moved my model to separate projects. The error is: Object mapping could not be fou开发者_StackOverflownd for Type with identity \'\'

I have a problem with EF. It started when I moved my model to separate projects. The error is:

Object mapping could not be fou开发者_StackOverflownd for Type with identity ''

My code:

protected EntityKey Key(int id)
{
    return new EntityKey(InstanceContext.GetType().Name + "." + typeof(T).Name, "Id", id);
}

protected object CurrentObject(int id)
{
    return InstanceContext.GetObjectByKey(Key(id)); //**<-- error**
} 

What is worse, when I put a break-point, it works fine. I get the entity without a problem.

0

精彩评论

暂无评论...
验证码 换一张
取 消