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

  • SEARCH
  • Home
  • 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 6717517
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:51:43+00:00 2026-05-26T08:51:43+00:00

I get the exception ‘The entity type [TYPE] is not part of the model

  • 0

I get the exception ‘The entity type [TYPE] is not part of the model for the current context.’ when trying to run my application.

My best guess so far is that it doesn’t recognize my type as a type that it has mapped. This could very well be since it is a type loaded at runtime. This type comes from a different assembly.

How does EF: CF find all it’s entities to map, and how can I make it find my types ?

  • 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-26T08:51:44+00:00Added an answer on May 26, 2026 at 8:51 am

    EF is not designed to support this feature directly. EF is ORM and ORM is mostly created for purpose when you specify types you want to use and map at design time and simply use them at runtime. It doesn’t mean that it is not possible to create types at runtime (with code mapping) but it is much more complex.

    Context must know about all types it should map and about their mapping. If you create context with no reference to your new type it simply doesn’t know about it. How to solve it? I can think about two options:

    • Emit context code as well and make sure that emitted context code contains public property of type DbSet<YourEmittedEntityType> (to use default mapping conventions) or emit OnModelCreating method as well to specify custom mapping.
    • Emit configuration (derived from EntityTypeConfiguration<YourEmittedEntityType>) class for your new entity as well. This class will specify mapping of new entity to your database table. Once you have your configuration you can manually create DbModelBuilder register all necessary entity type configuration including your new ones created at runtime, build DbModel, compile it and use DbCompiledModel to construct new instance of the DbContext. Just make user you cache DbCompiledModel for subsequent usages because its construction is very time consuming.

    In both cases make sure that table used to persist and retrieve new entity is already created and turn off any database initializers – you must maintain your database manually.

    Sure this is only the first step. Now you need to emit / generate code which will use your new entity and context – be aware that EF doesn’t work with interfaces and inheritance is handled specially so in the most scenarios you need code working with your emitted type directly.

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

Sidebar

Related Questions

I get this exception on my Windows 7 64bit in application running in VS
When using Marshal.GetExceptionCode() how do you get the Exception Type and/or instance of the
I am trying to set the innerxml of a xmldoc but get the exception:
If I use Microsoft.ApplicationServer.Caching.Client and Microsoft.ApplicationServer.Caching.Core assembly I get exception: The type or namespace
In a Spring, JPA, Hibernate project I'm trying to get exception handling working. For
I try to rethrow an exception, but it's not working. I get 'Exception was
I've got a folder: c:\test I'm trying this code: File.Move(@c:\test\SomeFile.txt, @c:\test\Test); I get exception:
When I try to map over a string, I get: Exception: Sequence does not
I've got a Polish version of Windows installed and therefore I get exception messages
I get security exception when using System.Net.WebClient to do HTTP requests, which is due

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.