Dot Net Entity Framework database update does not create tables in mysql database

I use MySql as a database with an official provider of communications. I am trying to use the following sample project (asp.net core 1.0) on mac:

 public class BloggingContext : DbContext { public BloggingContext(DbContextOptions<BloggingContext> options) : base(options) { } public DbSet<Blog> Blogs { get; set; } public DbSet<Post> Posts { get; set; } } public class Blog { public int BlogId { get; set; } public string Url { get; set; } public List<Post> Posts { get; set; } } public class Post { public int PostId { get; set; } public string Title { get; set; } public string Content { get; set; } public int BlogId { get; set; } public Blog Blog { get; set; } } 

And in my Startup.cs

  public void ConfigureServices(IServiceCollection services) { var connection = @"server=localhost;userid=efcore;port=3306;database=blogsFinal;sslmode=none;"; services.AddDbContext<BloggingContext>(options => options.UseMySQL(connection)); // Add framework services. services.AddMvc(); } 

In my .json project, I also add

 "dependencies": { ... "MySql.Data.EntityFrameworkCore": "7.0.5-ir21", "Microsoft.EntityFrameworkCore.Tools": { "version": "1.0.0-preview2-final", "type": "build" } } 

and

  "tools": { ..., "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final" }, 

When I run dotnet ef migrations add v1 , it works fine and creates migration files, but when I run dotnet ef database update , the database is created, but the tables are not displayed and gives this output

 System.NotImplementedException: The method or operation is not implemented. at MySQL.Data.EntityFrameworkCore.Migrations.Internal.MySQLHistoryRepository.get_ExistsSql() at Microsoft.EntityFrameworkCore.Migrations.HistoryRepository.Exists() at Microsoft.EntityFrameworkCore.Migrations.HistoryRepository.GetAppliedMigrations() at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.Migrate(String targetMigration) at Microsoft.EntityFrameworkCore.Design.MigrationsOperations.UpdateDatabase(String targetMigration, String contextType) at Microsoft.EntityFrameworkCore.Tools.Cli.DatabaseUpdateCommand.<>c__DisplayClass0_0.<Configure>b__0() at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args) at Microsoft.EntityFrameworkCore.Tools.Cli.Program.Main(String[] args) The method or operation is not implemented. 
+7
c # database mysql asp.net-core entity-framework
source share
2 answers

Exceptions speak of this. Oracle's official MySQL provider does not yet support migration or scaffolding.

It will only create the database the first time context.Database.EnsureCreated() executed. Any changes made after this will not apply. You must delete the entire database and create a new one, losing all the data.

Say thanks to Oracle;)

Update

With the release of 7.0.6-IR31 package, migrations work, but scaffolding still does not work.

+7
source share

As Tseng said, this is a known issue. Here is the bug report dated September 14, 2016.

There is no implementation for starting primary migration of the main EntityFramework code

http://bugs.mysql.com/bug.php?id=82981

+1
source share

All Articles