none
No context type was found in the assembly RRS feed

  • Question

  • Hello,

    When trying to enable migrations to my model I got this error message:

    "No context type was found in the assembly 'MyAssembly'.

    And I have a context type as:

     public class PBDBConnection : DbContext
        {
            public PBDBConnection()
                : base("name=PBDBConnection")
            {
            }
        
            protected override void OnModelCreating(DbModelBuilder modelBuilder)
            {
                throw new UnintentionalCodeFirstException();
            }
        
        }

    Any idea?

    Friday, May 16, 2014 8:27 AM

Answers

  • Hi Muris;

    When you enabled migration through the Package Manager Console did you set the default project dropdown to the project that the Entity Framework was created in? See image.

    Default project dropdown 


    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Monday, May 19, 2014 1:21 AM
  • Hi Fernando Soto.

    It solved my problem. I did not set the project where my DBContext was placed. Thanks.

    • Marked as answer by Muris Thursday, May 22, 2014 12:26 PM
    Thursday, May 22, 2014 12:26 PM

All replies

  • Any help in how to start tackling this problem?
    Sunday, May 18, 2014 5:03 PM
  • Hi Muris;

    When you enabled migration through the Package Manager Console did you set the default project dropdown to the project that the Entity Framework was created in? See image.

    Default project dropdown 


    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Monday, May 19, 2014 1:21 AM
  • Hi Fernando Soto.

    It solved my problem. I did not set the project where my DBContext was placed. Thanks.

    • Marked as answer by Muris Thursday, May 22, 2014 12:26 PM
    Thursday, May 22, 2014 12:26 PM
  • You marked the wrong post as the solution, you marked your reply to my solution.

    Have a great day.


    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Thursday, May 22, 2014 12:29 PM