mysql没有实体框架_NET实体框架数据库更新未在MySQL数据库中创...

我使用MySql作为官方连接提供程序的数据库.我正在Mac上的下一个项目示例(asp.net core 1.0)中进行尝试:

public class BloggingContext : DbContext

{

public BloggingContext(DbContextOptions options)

: base(options)

{ }

public DbSet Blogs { get; set; }

public DbSet Posts { get; set; }

}

public class Blog

{

public int BlogId { get; set; }

public string Url { get; set; }

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

}

在我的Startup.cs中

public void ConfigureServices(IServiceCollection services)

{

var connection = @"server=localhost;userid=efcore;port=3306;database=blogsFinal;sslmode=none;";

services.AddDbContext(options => options.UseMySQL(connection));

// Add framework services.

services.AddMvc();

}

在我的project.json中,我还添加

"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"

},

当我运行dotnet ef迁移时,添加v1可以正常工作并创建迁移文件,但是当我执行dotnet ef数据库更新时,会创建数据库,但不会创建表并抛出此输出

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.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
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值