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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:59:18+00:00 2026-06-17T20:59:18+00:00

So that I could keep my context clean and simple, I put a lot

  • 0

So that I could keep my context clean and simple, I put a lot of logic in an abstract class and made my context inherit from it.

I saw this approach here but now since my class no longer inherits directly from DBContext I can’t create migrations.

My abstract class is

public abstract class MyContext : DbContext
{

    public MyContext(string connString)
        : base(connString)
    {
    }
   public override int SaveChanges()
    {
        // custom code here
    }
}

Now when I try and create an migration by typing add-migration at the PM console I get an error indicating that a class inheriting from DBContext cannot be found

The PM console shows

PM> add-migration kirsten2 No migrations configuration type was found in the assembly 'DataLayer'. (In Visual Studio you can use the Enable-Migrations command from Package Manager Console to add a migrations configuration). 
PM> Enable-Migrations No context type was found in the assembly 'DataLayer'. 
  • 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-17T20:59:19+00:00Added an answer on June 17, 2026 at 8:59 pm

    If you search the EF repo for this error message (“No migrations configuration type was found”), you’ll find this resource in EntityFramework/Properties/Resources.cs file:

    /// <summary>
    /// A string like "No migrations configuration type was found in the assembly '{0}'. (In Visual Studio you can use the Enable-Migrations command from Package Manager Console to add a migrations configuration)."
    /// </summary>
    internal static string AssemblyMigrator_NoConfiguration(object p0)
    {
        return EntityRes.GetString(EntityRes.AssemblyMigrator_NoConfiguration, p0);
    }
    

    The next step would be search for AssemblyMigrator_NoConfiguration usage, and you’ll find
    just one occurence which is in EntityFramework/Migrations/Design/ToolingFacade.cs:

    private DbMigrationsConfiguration FindConfiguration()
    {
        var configurationType = FindType<DbMigrationsConfiguration>(
            ConfigurationTypeName,
            types => types
                         .Where(
                             t => t.GetConstructor(Type.EmptyTypes) != null
                                  && !t.IsAbstract
                                  && !t.IsGenericType)
                         .ToList(),
            Error.AssemblyMigrator_NoConfiguration,
            (assembly, types) => Error.AssemblyMigrator_MultipleConfigurations(assembly),
            Error.AssemblyMigrator_NoConfigurationWithName,
            Error.AssemblyMigrator_MultipleConfigurationsWithName);
    
        return configurationType.CreateInstance<DbMigrationsConfiguration>(
            Strings.CreateInstance_BadMigrationsConfigurationType,
            s => new MigrationsException(s));
    }
    

    I think now it would be easier to track the error and fix it.

    I’ve tested it on Source code and the message was irrelevant, turns out that the rel cause is a target framework tag in app.config.

    Here is the similar question with right answer:
    'Enable-Migrations' fails after upgrading to .NET 4.5 and EF 5

    Interesting that If you run Enable-Mirations and Add-Migration pointing exactly to Context class name and Configuratin class name respectively, it works fine.
    But the mentioned solution is the right solution and is easier also 🙂

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

Sidebar

Related Questions

I have a view that could be called from any of 3 actions from
I want to create a helper method that could be called from different code-behind
I made a image thread class that runs the update method in the instance
I need a function that could generate a regex. For example if I write
This seems like something that could be quite useful and yet and I can't
Is there a method that could tell for a string like foo bar Foo
I have a string of digits that could vary in length and I want
I am doing some server stuff that could potentially fail (not likely) but something
What UI mockup tools exist that could be used to produce designs that look
I'm trying to write a code that could print something like this -xv -xvv

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.