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 6829005
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:26:59+00:00 2026-05-26T22:26:59+00:00

The FluentAPI can not create a relational model based on the code below: public

  • 0

The FluentAPI can not create a relational model based on the code below:

public class Project
{
    public Guid ID { get; private set; }
    public string Name { get; set; }
    public virtual ICollection<string> Images { get; set; }
}

public class ProjectConfiguration : EntityTypeConfiguration<Project>
{
    public ProjectConfiguration()
    {
        HasKey(p => p.ID)
            .Property(p => p.ID)
                .IsRequired();

        Property(p => p.Name)
            .HasMaxLength(60)
            .IsRequired();

        HasRequired(p => p.Images).WithMany(); //???? Correct ??
        //HasMany(p => p.Images);  //???? Correct ??
    }
}

Error

The navigation property 'Images' is not a declared property on type 'Project'. Verify that it has not been explicitly excluded from the model and that it is a valid navigation property.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.InvalidOperationException: The navigation property 'Images' is not a declared property on type 'Project'. Verify that it has not been explicitly excluded from the model and that it is a valid navigation property.

Source Error: 


Line 58:         public IQueryable<Project> GetAll(int pageIndex, int pageSize, params Expression<Func<Project, object>>[] includeProperties)
Line 59:         {
Line 60:             return includeProperties.Aggregate<Expression<Func<Project, object>>,
Line 61:                 IQueryable<Project>>(Context.Projects, (current, includeProperty) => current.Include(includeProperty)).OrderBy(p => p.Name).Skip(pageIndex).Take(pageSize);
Line 62:         }

The following code ProjectRepository.cs

public IQueryable<Project> GetAll(params Expression<Func<Project, object>>[] includeProperties)
{
    return includeProperties.Aggregate<Expression<Func<Project, object>>,
        IQueryable<Project>>(Context.Projects, (current, includeProperty) => current.Include(includeProperty));
}

public IQueryable<Project> GetAll(int pageIndex, int pageSize, params Expression<Func<Project, object>>[] includeProperties)
{
    return includeProperties.Aggregate<Expression<Func<Project, object>>,
        IQueryable<Project>>(Context.Projects, (current, includeProperty) => current.Include(includeProperty)).OrderBy(p => p.Name).Skip(pageIndex).Take(pageSize);
}
  • 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-05-26T22:27:00+00:00Added an answer on May 26, 2026 at 10:27 pm

    Mapping of collections of primitive types is not supported, they are not valid navigation properties. You will have to define an entity class and use it instead of string in the Images collection:

    public class Image
    {
        public int Id { get; set; }
        public string Name { get; set; }
    }
    
    public class Project
    {
        // ...
        public virtual ICollection<Image> Images { get; set; }
    }
    

    The new entity Image will be mapped to its own new table. You can then define a mapping in Fluent API:

    public ProjectConfiguration()
    {
        // ...
        HasMany(p => p.Images).WithRequired();
        // for a one-to-many relationship
        // it will also setup cascading delete
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Setup Using MVC 3 + Code First Here are my classes public class Member
public class Foo { public string FooId{get;set;} public Boo Boo{get;set;} } public class Boo
public class Client { public Int32 ClientID { get; set; } public virtual ICollection<Inquiry>
I have a class: public class classParty { private int _arrivedCount; public int PartyID
i have these models: public class Student { public int Id { get; set;
Using ASP.NET MVC when I create my model, then a controller based on the
Background We have a WinForms application with Entity Framework 4.2 code-first / FluentAPI using
Background: We have a project with many modules. We're using EntityFramework 4.2 with FluentAPI
I feel silly asking this, but, I just can't work out how to create
Given the following two interfaces (these are small examples, not my actual implementation): public

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.