引用Entity Framework命名空间时,键入或命名空间未找到错误

时间:2013-01-31 07:19:40

标签: c# asp.net entity-framework web

我在我的网站上添加了一个ADO.Net实体数据模型,并将其命名为WebSocketModel。因此,它的所有代码都是在name space WebSocketModel文件夹内的App Code内生成的。

但现在我无法引用此namespace。我需要使用context classes内创建的namespace来解雇LINQ queries

我尝试通过网络表单中的namespace语句引用using WebSocketModel;,但收到错误

The type or namespace name 'WebSocketModel' could not be found 
(are you missing a using directive or an assembly reference?)

更令人困惑的是,每当我输入using intellisense时,会自动建议命名空间WebSocketModel。但是,稍后当我构建我的网站时,我得到了上述错误。

1 个答案:

答案 0 :(得分:1)

确定花了很长时间但终于解决了这个问题......我刚刚删除了实体模型并再次添加了它。这样做之后,我收到了一个新错误:

The type 'PatientBPData' is not attributed with EdmEntityTypeAttribute but is contained in an assembly attributed with EdmSchemaAttribute. POCO entities that do not use EdmEntityTypeAttribute cannot be contained in the same assembly as non-POCO entities that use EdmEntityTypeAttribute.

为了解决这个问题,我发现this非常有帮助