I'm getting started with EF Core 2.0, I have a console application targetting .NET 4.6.1 I have a very simple model class, and this context:
public class ContextCore : DbContext
{
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseSqlServer(ConfigurationManager.ConnectionStrings["efCoreCon"].ConnectionString);
}
public DbSet<ModelC> Models { get; set; }
}
this is the connection string:
<add name="efCoreCon" connectionString="server=PC-MSHWF\SQLEXPRESS;database=efCoreDB;integrated security=true;" />
I noticed that there's no command for Enable-Migrations
in ef core from the official docs
so I run Add-migration firstMigration
but I got this error:
No migrations configuration type was found in the assembly 'NewConsole'. (In Visual Studio you can use the Enable-Migrations command from Package Manager Console to add a migrations configuration).
when I tried Enable-Migrations , I got this error:
No context type was found in the assembly 'NewConsole'.
Entity Framework Core uses this table in the database to keep track of which migrations have already been applied to the database. This ensures that that Database. Migrate() call, or alternatively, the Update-Database call from the command line doesn't try to execute the same migrations over and over again.
Go to the Package Manager Console and install the needed tools with Install-Package Microsoft.EntityFrameworkCore.Tools
. When it has completed try to use the command EntityFrameworkCore\Add-Migration firstMigration
.
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