0

I just added a couple fields to my stored procedure, which connects to my MVC app using EF, but the new fields are returning null values, even though the model has been updated and seems fine....

//------------------------------------------------------------------------------
// <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
    }
}

I've updated SPs many times.

The only thing unusual that happened this time, was that there was a bit of confusion during the process, since I had to remove references to a temp table in order to get it to update the model. (Entity Framework can't handle a simple table variable?) This problem happens now even when my temp table is completely removed from the query.

The strangest thing is that even though THIS test column has been added to the model, it is still returning no data to the added field. An additional "test" field where I hardcoded a value into the query:

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

How can the test field return null when I hardcoded a value to it?

EDIT: I went ahead and recreated the entire model which fixed the problem. I'm keeping the old one until I can figure out exactly what the difference is between the two, and will post back when (or, big if) I find out.

Community
  • 1
  • 1
Dave
  • 4,949
  • 6
  • 50
  • 73
  • The stored procs are a two step process correct? Refresh the schema, to make the proc known to the model, then you have to create the mapping to the entity. Sounds like you did the refresh, but didn't add the new columns to the mapping? – Mike May 23 '14 at 19:41
  • I see how it might look that way, but I did "update the model from database" and then went into the Model Browser and click "Get column information" then "Update" and then Ok. I think these are all the steps... – Dave May 23 '14 at 19:58

0 Answers0