EF:新存储过程字段返回空值

时间:2014-05-23 16:06:06

标签: entity-framework visual-studio-2012

我刚刚在我的存储过程中添加了几个字段,它使用EF连接到我的MVC应用程序,但新字段返回空值,即使模型已更新并且看起来很好......

//------------------------------------------------------------------------------
// <auto-generated>
//    This code was generated from a template.
//
//    Manual changes to this file may cause unexpected behavior in your application.
//    Manual changes to this file will be overwritten if the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace MyNamesSpace
{
    using System;

    public partial class MyStoredProcedure_Result
    {
        public Nullable<int> myfield1 { get; set; }
        public string myfield2 { get; set; }
        public string myfield3 { get; set; }
        public Nullable<int> myfiel14 { get; set; }
        public string myNEWFIELD { get; set; }  // always returns null
        public string test { get; set; }  // always returns null
    }
}

我已多次更新SP。

这次发生的唯一不寻常的事情是,在此过程中出现了一些混乱,因为我必须删除对临时表的引用才能让它更新模型。 (Entity Framework can't handle a simple table variable?)即使从查询中完全删除了临时表,也会出现此问题。

最奇怪的是,即使已将此测试列添加到模型中,它仍然不会向添加的字段返回任何数据。另外一个&#34;测试&#34;我将值硬编码到查询中的字段:

Select from mytable
[..other query lines..]
"test" as test 

当我对一个值进行硬编码时,测试字段如何返回 null

编辑:我继续并重新创建了修复问题的整个模型。我保留旧的,直到我能确切地知道两者之间的区别,并且会在我发现的时候(或者,如果很大的话)发回。

0 个答案:

没有答案