小编The*_*ain的帖子

无法从“字符串”转换为“Microsoft.EntityFrameworkCore.ServerVersion”

我正在使用 C# 并且有一个错误: Argument 2: cannot convert from 'string' to 'Microsoft.EntityFrameworkCore.ServerVersion'

    using Microsoft.EntityFrameworkCore;
    using System;
    
    namespace Infrastructure
    {
        public class BotContext : DbContext 
        {
            public DbSet<Server> Servers { get; set; }
    
            protected override void OnConfiguring(DbContextOptionsBuilder options)
                => options.UseMySql("server=localhost;user=root;port=3306;Connect Timeout=5;");
    
            public class Server
            {
                public ulong Id { get; set; }
                public string Prefix { get; set; }
            }
        }
    }
Run Code Online (Sandbox Code Playgroud)

c# mysql entity-framework-core

4
推荐指数
2
解决办法
2811
查看次数

找不到方法:“System.Object Microsoft.EntityFrameworkCore.Infrastruct.IAnnotatable.get_Item(System.String)”

我正在使用 C#,我想要Add-Migration InitialVersion但有一个问题:

Method not found: 'System.Object Microsoft.EntityFrameworkCore.Infrastructure.IAnnotatable.get_Item(System.String)'

我使用的 Nuget 包:

<Project Sdk="Microsoft.NET.Sdk">

 <PropertyGroup>
   <TargetFramework>net5.0</TargetFramework>
 </PropertyGroup>

 <ItemGroup>
   <PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.0-preview.2.21154.2" />
   <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.0-preview.2.21154.2">
     <PrivateAssets>all</PrivateAssets>
     <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
   </PackageReference>
   <PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="5.0.0-alpha.2" />
 </ItemGroup>

</Project>
Run Code Online (Sandbox Code Playgroud)

.net c# mysql entity-framework pomelo-entityframeworkcore-mysql

4
推荐指数
1
解决办法
4429
查看次数