当另一个项目中的实体时,Context具有null属性

时间:2012-05-16 14:01:27

标签: c# .net entity-framework t4

我正在使用EF,我生成了两个tt文件。我离开了ServerComponents项目中的context.tt。我将实体.tt文件移动到Common项目,由解决方案中的所有项目共享。问题是上下文对象中的所有属性/实体在运行时都是null,我无法弄清楚原因。这就像我的context.tt不知道新实体在哪里,但我不知道如何解决这个问题。有谁知道我错过了什么?

以下是服务器项目:

enter image description here

以下是常见项目:

enter image description here

这是运行时的上下文状态:

enter image description here

我在这里尝试了很多东西。我希望有人知道这个答案......

1 个答案:

答案 0 :(得分:0)

我想我明白了。通过反复试验,使CustodianEntities属性公开工作(它们是内部的)。这是在DataCustodianContext.context.cs中。现在我只需要改变tt文件以确保它在再次生成时保持公开。

我考虑过删除这个问题,但我希望这可能会帮助别人。

enter image description here