2016-09-22 12 views
7

Tôi đang sử dụng MySql làm cơ sở dữ liệu với nhà cung cấp kết nối chính thức. Tôi đang cố gắng nó với ví dụ dự án tiếp theo (asp.net lõi 1.0) trên một mac:Cập nhật cơ sở dữ liệu Khuôn khổ thực thể Net Net không tạo bảng trong cơ sở dữ liệu mysql

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; } 
} 

Và trong Startup.cs tôi

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(); 
    } 

Trong project.json của tôi, tôi cũng thêm

"dependencies": { 
    ... 
    "MySql.Data.EntityFrameworkCore": "7.0.5-ir21", 

    "Microsoft.EntityFrameworkCore.Tools": { 
     "version": "1.0.0-preview2-final", 
     "type": "build" 
    } 
} 

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

Khi tôi chạy 01., hoạt động tốt và tạo ra các tập tin chuyển đổi, nhưng khi tôi thực hiện dotnet ef database update cơ sở dữ liệu được tạo ra nhưng bàn không và ném ra này

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. 
+0

Ông có thể xin vui lòng gửi mã được thực hiện cho biết Update, đó là ném lỗi? – A3006

+0

Đây là mã [link] (https://github.com/careuno/newtestEfcoreMysql) lỗi là khi tôi thực thi cập nhật cơ sở dữ liệu dotnet ef –

Trả lời

7

Exceptions nói nó. Các nhà cung cấp MySQL chính thức từ Oracle không hỗ trợ nó di cư hoặc giàn giáo được nêu ra.

Nó sẽ chỉ tạo Cơ sở dữ liệu vào lần thực hiện đầu tiên context.Database.EnsureCreated(). Bất kỳ thay đổi nào được thực hiện sau đó sẽ không được áp dụng. Bạn phải thả toàn bộ DB và tạo một DB mới, mất tất cả dữ liệu.

nói nhờ Oracle;)

Cập nhật

Với việc phát hành 7.0.6-IR31 package di cư làm việc, nhưng giàn giáo vẫn không.

+3

Cảm ơn bạn, Với SapientGuardian.EntityFrameworkCore.MySql hoạt động tốt –

+0

Một liên kết đến tài liệu sẽ có ích. –

1

Như Tseng đã nói, đây là một vấn đề đã biết. Đây là báo cáo lỗi từ ngày 14 tháng 9 2016.

Thiếu thực hiện để chạy mã EntityFramework lõi đầu tiên di cư

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

Các vấn đề liên quan