Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8407817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:28:18+00:00 2026-06-09T23:28:18+00:00

Hi i’m getting error CS1061 when calling a partialview from a controller. I’m using

  • 0

Hi i’m getting error CS1061 when calling a partialview from a controller.
I’m using a solution with separate projects containing Mvc and EF.

My model are a Menu and MenuItem entities (abreviated from EF):

public partial class Menu : EntityObject
{
#region Propiedades primitivas
public global::System.Int32 Id
public global::System.String Name
#region Propiedades de navegación
[EdmRelationshipNavigationPropertyAttribute("DAL_EF_Model", "MenuMenuItem", "MenuItem")]
    public EntityCollection<MenuItem> MenuItems

…

public partial class MenuItem : EntityObject
{
#region Propiedades primitivas
public global::System.Int32 Id
public global::System.String Name
public global::System.String ActionName
public global::System.String ControllerName
public global::System.String Url

…

The Controller is:
…

    [AcceptVerbs(HttpVerbs.Get)]
    public ActionResult MenuLayout(string name)
    {
        if (db.Menus.Count<Menu>() > 0 &&
            db.MenuItems.Count<MenuItem>() > 0)
        {
            //var todos = new MenuV();
            //todos = db.Menus.ToList();
            List<Menu> otros = db.Menus.ToList();
            foreach (var opcion in db.Menus)
            {
                List<Menu> menu = db.Menus
                    .Include("MenuItems")
                    .ToList();
                    //.Single<Menu>(m => m.Name == opcion.Name);
                return PartialView("_MenuLayout", menu);
            }
            return PartialView("_MenuLayout", null);
        }
        else
        {
            return PartialView("_MenuLayout", null);
        }
    }

…

And the partialview _MenuLayout.cshtml:

@model IEnumerable<DAL_EF.Menu>
<div id="accordion">
 <div><h3><a href="#"> ERP </a></h3>
   @{
    if (Model != null)
    {
        <div><ul>
        @foreach (var item in Model.MenuItems)
        {
            <li id="@item.Name">@Html.ActionLink(
            @item.Name,
            @item.ActionName,
            @item.ControllerName)</li>
        }
        </ul></div>
    }
}
 </div> 
</div>

The error occurs in the

IEnumerable<DAL_EF.Menu>

If i use

.Single<Menu>

from controller and the partialview receives

 DAL_EF.Menu

it works fine.

The complete error message is:

    {"_MenuLayout.cshtml(21): error CS1061: 'System.Collections.Generic.IEnumerable<DAL_EF.Menu>' no contiene una definición de 'MenuItems' ni se encontró ningún método de extensión 'MenuItems' que acepte un primer argumento de tipo 'System.Collections.Generic.ICollection<DAL_EF.Menu>' (¿falta una directiva using o una referencia de ensamblado?)"}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T23:28:19+00:00Added an answer on June 9, 2026 at 11:28 pm
    @model IEnumerable<DAL_EF.Menu>
    

    This specifies that your model is of type IEnumerable< DAF_EL.Menu >. However, you are using the model as if it were of type DAL_EF.Menu.

    @foreach (var item in Model.MenuItems)
    

    As the error message says, IEnumerable< DAL_EF.Menu > (which is what your Model is) doesn’t have a property called MenuItems, because it’s a whole bunch of Menus, not just a single Menu.

    You probably want something like this, to loop through each Menu in your model, and then loop through each MenuItem in each menu.

    @foreach (Menu menu in Model)
    {
        @foreach(var item in menu.MenuItems)
        {
            .. do your stuff ..
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
We are using XSLT to translate a RIXML file to XML. Our RIXML contains

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.