Query error after upgrade to v12

Hey guys,

I'm getting a problem in my project, before I upgrade my database to v12 my webapp worked perfectly, but after, every time that I execute query to show a column in a dropdownlist I receive this message "The data reader has more than one field. Multiple fields are not valid for EDM primitive or enumeration types.".

Actually, everytime when I try to read the DataBase, I receive this message. Independent what I'm trying to do

Someone had the same problem, or something like that?

Threre is my code.
    ApplicationDbContext context = new ApplicationDbContext();
    string user = User.Identity.GetUserId();

    System.Collections.Generic.List<SelectListItem> Devices = new System.Collections.Generic.List<SelectListItem>();

    var sqlcmd = "SELECT Nick FROM dbo.AspNetDevice WHERE OwnerID = '" + user + "' ORDER BY Nick ASC";
    context.Database.Connection.Open();
    try
    {
        var GetDevice = context.Database.SqlQuery<string>(sqlcmd);
        int count = GetDevice.Count(); int i = 0;
        if (count > 0)
        {
            Devices.Add(new SelectListItem { Text = "Selecione o Dispositivo", Selected = true, Disabled = true });
            while (i != count)
            {
                Devices.Add(new SelectListItem { Value = GetDevice.ElementAt(i), Text = GetDevice.ElementAt(i) });
                i++;
            }
        }else
        {
            Devices.Add(new SelectListItem { Text = "Adicione um Dispositivo", Selected = true, Disabled = true });
        }
    }
    finally
    {
        context.Database.Connection.Close();
    }


August 19th, 2015 6:28pm

Hi Felipe,

Not sure on what line the error occurs. But somewhere not shown here the definition of the reader is incorrect.

Free Windows Admin Tool Kit Click here and download it now
September 1st, 2015 2:58pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics