gpt4 book ai didi

c# - 找不到 ASP.NET Core 2 MySQL 8.0.8-dmr Entity Framework 扩展

转载 作者:行者123 更新时间:2023-11-29 02:44:01 25 4
gpt4 key购买 nike

将 ASP.NET Core Web 应用程序升级到 .NET Core 2.0,我在升级到 MySQL 8.0.8-dmr 版本后找不到 MySQL 扩展方法时遇到困难。

MySQL Data Entity Framework Core 升级到 8.0.8-dmr

$ dotnet add package MySql.Data.EntityFrameworkCore --version 8.0.8-dmr

在我的 Startup.cs 中,我有:

using MySQL.Data.EntityFrameworkCore;
using MySQL.Data.EntityFrameworkCore.Extensions;

但是在 MySQL 8.0.8-dmr 版本中,找不到 Extensions 命名空间。

error CS0234: The type or namespace name 'Extensions' does not exist in the namespace 'MySql.Data.EntityFrameworkCore' (are you missing an assembly reference?)

这是使用 MySQL 所必需的,如 ConfigureServices() 所示:

public void ConfigureServices(IServiceCollection services)
{
services.AddDbContext<ApplicationDbContext>(options =>
options.UseMySQL(Configuration.GetConnectionString("DefaultConnection")));

如果没有扩展方法,这会导致:

error CS1061: 'DbContextOptionsBuilder' does not contain a definition for 'UseMySQL' and no extension method 'UseMySQL' accepting a first argument of type 'DbContextOptionsBuilder' could be found

在 ASP.NET Core 2 Web 应用程序中使用 MySQL 是否有不同的方法?

最佳答案

正如评论中指出的那样,尝试更改大小写,即 UseMysql。还要检查 nuget 包还原警告。

关于c# - 找不到 ASP.NET Core 2 MySQL 8.0.8-dmr Entity Framework 扩展,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45853189/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com