Unable to create an object of type 'EcommerceContext'. For the different patterns supported at design time

270 views Asked by At
public class EcommerceContext : IdentityDbContext<IdentityUser>
{

    public EcommerceContext(DbContextOptions options) : base(options)
    {
    }


// use real database
        services.AddDbContext<EcommerceContext>(c =>
            c.UseSqlServer(Configuration.GetConnectionString("EcommerceConnection"),
                x => x.MigrationsAssembly("Ecommerce.Web")));

PM> add-migration InitializeDb Build started... Build succeeded. Unable to create an object of type 'EcommerceContext'. For the different patterns supported at design time, see https://go.microsoft.com/fwlink/?linkid=851728

1

There are 1 answers

0
Wael Galal El Deen On

In my case the solution had multiple startup projects. Anit was fixed by defining only one startup project.