简体   繁体   English

迁移在 JetBrains Rider 中不起作用

[英]Migration doesn't work in JetBrains Rider

I'm trying to update the database with migration using Rider JetBrains, but when I try to "add migration" it gives me an error in the console.我正在尝试使用 Rider JetBrains 通过迁移更新数据库,但是当我尝试“添加迁移”时,它在控制台中出现错误。 I believe this error is happening because my XML is causing this error because in case I don't change it to use my database connection string, the "add migration" works successfully (my database is MySQL).我相信这个错误正在发生,因为我的 XML 导致了这个错误,因为如果我不将它更改为使用我的数据库连接字符串,“添加迁移”会成功运行(我的数据库是 MySQL)。

App.config:应用程序配置:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
   <connectionStrings>
      <add Server="127.0.0.1" Port="3306" Database="smartparking" Uid="root" 
      Pwd="1234567"></add>
   </connectionStrings>
</configuration>

My server我的服务器

My database我的数据库

You can also use a jetbrains plugin made for handling migrations您还可以使用为处理迁移而制作的 jetbrains 插件

https://plugins.jetbrains.com/plugin/17026--net-ef-migration-facilitator/ https://plugins.jetbrains.com/plugin/17026--net-ef-migration-facilitator/

Also or :也或:

Adding package references添加包引用

The first thing to do would be adding package references.首先要做的是添加包引用。 There are a few packages we'll be needing, the first four are typically already installed when working with Entity Framework Core:我们将需要一些包,前四个通常在使用 Entity Framework Core 时已经安装:

  • Microsoft.EntityFrameworkCore – the Entity Framework Core framework Microsoft.EntityFrameworkCore – 实体框架核心框架

  • Microsoft.EntityFrameworkCore.SqlServer – the SQL Server database driver (other databases are supported as well) Microsoft.EntityFrameworkCore.SqlServer – SQL Server 数据库驱动程序(也支持其他数据库)

  • Microsoft.EntityFrameworkCore.Design – the Entity Framework Core design tooling Microsoft.EntityFrameworkCore.Design – Entity Framework Core 设计工具

  • Microsoft.EntityFrameworkCore.SqlServer.Design – SQL Server-specific tooling Microsoft.EntityFrameworkCore.SqlServer.Design – 特定于 SQL Server 的工具

  • Microsoft.EntityFrameworkCore.Tools.DotNet – the cross-platform command line tools we are interested in Microsoft.EntityFrameworkCore.Tools.DotNet——我们感兴趣的跨平台命令行工具

this link is helpful for you :此链接对您有帮助:

https://blog.jetbrains.com/dotnet/2017/08/09/running-entity-framework-core-commands-rider/ https://blog.jetbrains.com/dotnet/2017/08/09/running-entity-framework-core-commands-rider/

EDIT :编辑 :

The sample of connection string :连接字符串示例:

<add name="ConnectionStringName"
    providerName="System.Data.SqlClient"
    connectionString="Data Source=ServerName;Initial Catalog=DatabaseName;Integrated Security=False;User Id=userid;Password=password;MultipleActiveResultSets=True" />

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM