1
votes

I am building a project in VS 2015 and I am trying to enable-migrations to create a database using Entity Framework, but I am getting an error:

Cannot determine a valid start-up project. Using project 'Data Manager' instead. Your configuration file and working directory may not be set as expected. Use the -StartUpProjectName parameter to set one explicitly. Use the -Verbose switch for more information. No context type was found in the assembly 'Data Manager'.

I found several threads and potential solutions, but no luck. So far I have tried:

  1. Rebuilding the Solution and Resetting VS

  2. I confirmed that the default project is set to 'DataManager' with both a 'nuget.org' and 'All' package source

  3. Enable-Migrations -ProjectName DataManager

  4. I reinstalled with the commmand: Install-Package EntityFramework -IncludePrerelease

What am I missing?

1
can you show the context class code ? - Sampath
Have you tried selecting project that contains your dbcontext from "default project" combobox in nuget console? - Den
So it seems like I am missing context... I am not sure where the context class code would be at and, if I am missing it, what should be in it... Assume it should be something around "dbcontext". I have seen and "Identity Models" model in the tutorial i am following that has an applicaitondbcontext class, but I assumed that was autogenerated... I will go to their github and see if I can replicate it by hand and then try to migrate - user2653814
How many projects are there in your solution? - Ravi Matani

1 Answers

0
votes

It seems you don't have a context class on your Data Manager project.You have to specify it as shown below.

namespace MigrationsAutomaticDemo
    {
        public class YourContext : DbContext
        {
            public DbSet<Blog> Blogs { get; set; }
        }

        public class Blog
        {
            public int BlogId { get; set; }
            public string Name { get; set; }
        }
    }

Hope it will work after that.

You can read more about it here : Automatic Code First Migrations