Using VS Community 2017. I have tried to create initial migration with error message saying:
Both Entity Framework Core and Entity Framework 6 are installed. The Entity Framework Core tools are running. Use 'EntityFramework\Add-Migration' for Entity Framework 6. No DbContext was found in assembly 'Test_Project'. Ensure that you're using the correct assembly and that the type is neither abstract nor generic.
... code in my dbcontext:
protected override void OnModelCreating(DbModelBuilder mb) { base.OnModelCreating(mb); mb.Entity<Stuff>().ToTable("Stuff"); } public DbSet<Stuff> Stuff{ get; set; }
From the Tools menu, select NuGet Package Manager > Package Manager Console. The enable-migrations command creates a Migrations folder in the ContosoUniversity project, and it puts in that folder a Configuration. cs file that you can edit to configure Migrations.
Open the Package Manager Console from Tools → Library Package Manager → Package Manager Console and then run the enable-migrations command (make sure that the default project is the project where your context class is).
In the Package Manager Console select the project where the DbContext
is defined and run the command add-migration initial
. For example:public class SomeContext : DbContext
You have to specify the project name where the DbContext is located. So just right on the Nugget PM Console, type: Add-Migration MigrationName -Project YourProjectName
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With