title: 'Microsoft.EntityFrameworkCore.Infrastructure.IDbContextFactory`1[TContext]' violates the constraint of type parameter 'TContext'
body: <p>It's my first time using asp 5\core1 and i'm having problem setting a entity framework dbcontext</p>
  
  <p>I have one class library with my object</p>
  
  <pre><code>public class Utilizador
      {
          public Utilizador()
          {
  
          }
  
          public int id { get; set; }
      }
  </code></pre>
  
  <p>Then i have a Web Api project with a reference to my class and a context</p>
  
  <pre><code>public class Context : DbContext
  {
      public Context(DbContextOptions&lt;Context&gt; options)
          : base(options)
      {
  
      }
  
      public DbSet&lt;Utilizador&gt; Utilizadores { get; set; }
  
  }
  </code></pre>
  
  <p>My package.json its like this regarding entity framework</p>
  
  <pre><code>"dependencies": {
      "Microsoft.NETCore.App": {
        "version": "1.0.0-rc2-3002702",
        "type": "platform"
      },
      "Microsoft.AspNetCore.Mvc": "1.0.0-rc2-final",
      "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-rc2-final",
      "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-rc2-final",
      "Microsoft.AspNetCore.Mvc.WebApiCompatShim": "1.0.0-rc2-final",
      "Microsoft.EntityFrameworkCore": "1.0.0-rc2-final",
      "Microsoft.EntityFrameworkCore.Tools":  "1.0.0-preview1-final" ,
      "Microsoft.EntityFrameworkCore.SqlServer": "1.0.0-rc2-final"
    },
  
    "tools": {
      "Microsoft.AspNetCore.Server.IISIntegration.Tools": {
        "version": "1.0.0-preview1-final",
        "imports": "portable-net45+win8+dnxcore50"
      },
      "Microsoft.EntityFrameworkCore.Tools": {
      "version": "1.0.0-preview1-final",
      "imports": [
        "portable-net45+win8+dnxcore50",
        "portable-net45+win8"
      ]
    }
    },
  
    "frameworks": {
      "netcoreapp1.0": {
        "imports": [
          "dotnet5.6",
          "dnxcore50",
          "portable-net45+win8"
        ]
      }
    }
  </code></pre>
  
  <p>And finally my startup.cs </p>
  
  <pre><code>            public void ConfigureServices(IServiceCollection services)
      {
          // Add framework services.
          services.AddMvc();
        services.AddEntityFramework().AddEntityFrameworkSqlServer().AddDbContext&lt;Context&gt;(options =&gt; options.UseSqlServer(Configuration["ConnectionStrings:DefaultConnection"]));
  
      }
  </code></pre>
  
  <p>I used the command Add-Migrations and it created my database and one table called __MigrationsHistory but didnt created any for my class so i used the Add-Migration "mycontext" and everything stopped working, now everytime i try to do a migration i get this error:</p>
  
  <pre><code>System.ArgumentException: GenericArguments[0], 'WebApiSolution.Migrations.Context', on 'Microsoft.EntityFrameworkCore.Infrastructure.IDbContextFactory`1[TContext]' violates the constraint of type 'TContext'. ---&gt; System.TypeLoadException: GenericArguments[0], 'WebApiSolution.Migrations.Context', on 'Microsoft.EntityFrameworkCore.Infrastructure.IDbContextFactory`1[TContext]' violates the constraint of type parameter 'TContext'.    at System.RuntimeTypeHandle.Instantiate(RuntimeTypeHandle handle, IntPtr* pInst, Int32 numGenericArgs, ObjectHandleOnStack type)
     at System.RuntimeTypeHandle.Instantiate(Type[] inst)
     at System.RuntimeType.MakeGenericType(Type[] instantiation)
     --- End of inner exception stack trace ---
      at System.RuntimeType.ValidateGenericArguments(MemberInfo definition, RuntimeType[] genericArguments, Exception e)
      at System.RuntimeType.MakeGenericType(Type[] instantiation)
      at Microsoft.EntityFrameworkCore.Design.DbContextOperations.FindContextFactory(Type contextType) 
      at Microsoft.EntityFrameworkCore.Design.DbContextOperations.FindContextTypes() 
     at Microsoft.EntityFrameworkCore.Design.DbContextOperations.FindContextType(String name)
     at Microsoft.EntityFrameworkCore.Design.DbContextOperations.CreateContext(String contextType)
     at Microsoft.EntityFrameworkCore.Design.MigrationsOperations.RemoveMigration(String contextType, Boolean force)
      at Microsoft.EntityFrameworkCore.Tools.Cli.MigrationsRemoveCommand.&lt;&gt;c__DisplayClass0_0.&lt;Configure&gt;b__0()
      at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args) 
     at Microsoft.EntityFrameworkCore.Tools.Cli.Program.Main(String[] args)
   GenericArguments[0], 'WebApiSolution.Migrations.Context', on 'Microsoft.EntityFrameworkCore.Infrastructure.IDbContextFactory`1[TContext]' violates the constraint of type 'TContext'.
  </code></pre>
  
  <p>Can someone please point me in the right direction? what am i doing wrong, what am i missing here?</p>
  
  <p>thanks</p>