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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T11:17:08+00:00 2026-05-28T11:17:08+00:00

I have an issue that has me stumped. We have a model assembly and

  • 0

I have an issue that has me stumped. We have a model assembly and a repositories assembly. The model layer contains classes that are mapped to our database by the DbContext derived repositories in the repositories layer. So far these have come along without a hitch.

In the model we have a one to many association Question 1 – * Answer (Question.Answers and Answer.Question are the mapped navigation properties). We now have a requirement to mark Question.Answers as internal as this does not make sense outside of the model. When we make the change from: public virtual IList<Answer> ... to internal virtual IList<Answer> ... we get the exception:

A specified Include path is not valid. The EntityType Repositories.Question does not declare a navigation property with the name Answers.

First of all, this exception is odd as it references the type Repositories.Question, which does not exist! It should be Model.Question.

The Model assembly already has InternalsVisibleTo set to Repositories:

[assembly: InternalsVisibleTo("Repositories")]

Which means that we do not get compile errors in the mapping code and we have tried the following:

[assembly: InternalsVisibleTo("EntityFramework")]
[assembly: InternalsVisibleTo("System.Data.Entity")]

But we still get the aforementioned exception.

Any ideas why we are getting this?


Edit

Ladislav Mrnka, thanks for the help! This is still causing us pain.

We have already defined the relationship using the fluent API:

modelBuilder.Entity<Answer>()
    .HasRequired(a => a.Question)
    .WithMany(q => q.Answers)
    .Map(x => x.MapKey("QuestionId"));

And this does work when the property q.Answers is set to public. The data is read and written to the database without issue. When we change it to internal, our code still compiles (as we’re using InternalsVisibleTo) but we get the above exception when we run our integration tests.

I have changed the connection string to a new catalog name and EF has no trouble creating the database and the expected constraints. So all is working as expected. The trouble only arises when changing the navigation property access modifier

Regards,

Stephen

  • 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-28T11:17:09+00:00Added an answer on May 28, 2026 at 11:17 am

    First of all, this exception is odd as it references the type
    Repositories.Question, which does not exist! It should be
    Model.Question.

    This is EF internals behavior. You have a class called Model.Question but EF internally has something called Repository.Question contained in the mapping – it was same with EDMX where you had a POCO class but the entity in the diagram had “different namespace”.

    It is possible that your internal navigation property wasn’t mapped. Can you try to create database from your model and validate that relation between Answers and Questions tables is correctly set up? If not try to define this relation explicitly with fluent API.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an issue that has got me pretty stumped, and would appreciate some
I have a strange issue that has arisen recently: Whenever I enter text, even
I have a database issue that i currently cannot wrap my head around with
I have come across a large issue that i am having that has suddenly
I've encountered a weird issue that has gotten me stumped for a few days
I an issue that has me completely stumped. I am simply running a simple
I have a production performance issue that I'm stumped on. I'm hoping that someone
I have issue that is reproduced on g++. VC++ doesn't meet any problems. So
I have an issue that is driving me a bit nuts: Using a UserProfileManager
I have an issue that seems like very flaky behavour, is this a problem

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.