【问题标题】:StackOverflowException: 'Exception_WasThrown' ErrorStackOverflowException:“Exception_WasThrown”错误
【发布时间】:2021-07-24 16:19:08
【问题描述】:

当我尝试将 MySql 与 Entity Framework Core(无密码)连接时,程序抛出 StackOverflowException: 'Exception_WasThrown。这是我的上下文和运行代码。

    public class LauncherContext : DbContext
    {
        public DbSet<User> Users { get; set; }

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            optionsBuilder.UseMySQL("Server=localhost;Database=dbname;user=root;password=");
        }

    }

using (LauncherContext context = new LauncherContext())
{
  return context.Users.SingleOrDefault(user => user.Username == "userUsername");
}

【问题讨论】:

  • 请也发布您的过滤器
  • @Sergey 我添加了过滤器。
  • 请添加异常中的堆栈跟踪

标签: c# mysql entity-framework entity-framework-core


【解决方案1】:

如果您的意思是窗口身份验证,您的连接字符串应该是这样的:

Server=myServerAddress;Database=myDataBase;IntegratedSecurity=yes;
Uid=auth_windows;

【讨论】:

  • 现在系统抛出 System.PlatformNotSupportedException: 'The option 'IntegratedSecurity' is not supported.' error.
  • 再检查一次你的服务器名和数据库名
  • 并检查是否安装了 MySql.Data.MySqlClient。将此命名空间添加到 using。
  • 我安装了 MySql.Data.MySqlClient 但我应该使用哪个文件添加它?数据库上下文?
  • 是的,使用 MySql.Data.MySqlClient 添加到文件中您的连接字符串在哪里
猜你喜欢
  • 1970-01-01
  • 2018-03-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-01-30
  • 1970-01-01
  • 1970-01-01
  • 2021-10-11
相关资源
最近更新 更多