VS 2019和MySQL Entity Framework复制数据库名称 [英] VS 2019 and MySQL Entity Framework duplicate database name

查看:59
本文介绍了VS 2019和MySQL Entity Framework复制数据库名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在项目中添加了Entity Framework,但是我调用了 toList()方法,但出现错误:

  okuldbEntities ent = new okuldbEntities();私有void Form1_Load(对象发送者,EventArgs e){dataGridView1.DataSource = ent.ogrenciler.ToList();} 

这是错误:

此异常最初是在此调用堆栈上抛出的:[外部代码]

内部异常1:MySqlException:表' okuldb.okuldb .ogrenciler'不存在

okuldb 是我的数据库名称,我没有找到为什么将它两次添加.

我看起来很多.我安装了VMWare再次完成了所有操作,但是得到了相同的结果.

我的步骤:

  1. 我下载Visual Studio 2019社区并安装它
  2. mysql安装程序,我安装mysql服务器8.0.22,Visual Studio连接器1.2.9和.net连接器8.0.22
  3. 我创建了c#项目netframework 4.8
  4. 在此之后,我转到nuget包并安装了实体框架6.4.4和mysql数据实体框架8.0.22和mysql数据8.0.22
  5. 毕竟,我可以为我的项目添加实体.

我添加datagridview1并编写以下代码:

  eokulEntities ent =新的eokulEntities();私有void Form1_Load(对象发送者,EventArgs e){dataGridView1.DataSource = ent.ogrencinot.ToList();} 

然后我运行并看到以下消息:

此异常最初是在此调用堆栈上抛出的:[外部代码]

内部例外1:MySqlException:表'eokul.eokul.ogrencinot'不存在

我尝试了太多方法.我找到了另一台笔记本电脑,对其进行了格式化,然后又重新安装了所有这些软件.

再次是相同的错误.

我该怎么办?

解决方案

1.关闭Visual Studio项目

2.使用记事本/或项目中的名称/编辑编辑Model1.edmx文件/

3.在文件中从Schema ="okuldb"替换匹配项.到Schema =""

4.保存Model1.edmx文件

5.打开Visual Studio项目

6.编译项目

7.运行应用程序

I added Entity Framework to my project but I call the toList() method and I'm getting an error:

okuldbEntities ent = new okuldbEntities();

private void Form1_Load(object sender, EventArgs e)
{
    dataGridView1.DataSource = ent.ogrenciler.ToList();
}

and this is the error:

This exception was originally thrown at this call stack: [External Code]

Inner Exception 1: MySqlException: Table 'okuldb.okuldb.ogrenciler' doesn't exist

okuldb is my database name and I didn't find why it added it twice.

I looked a lot. I installed VMWare did it all again, but got the same result.

my steps:

  1. i download visual studio 2019 community and install it
  2. mysql installer and i install mysql server 8.0.22, visual studio connector 1.2.9 and .net connector 8.0.22
  3. i create c# project netframework 4.8
  4. after this i go nuget package and i install entity framework 6.4.4 and mysql data entityframework 8.0.22 and mysql data 8.0.22
  5. after all this i can add entity my project.

i add datagridview1 and i write this code:

 eokulEntities ent = new eokulEntities();
        private void Form1_Load(object sender, EventArgs e)
        {
            dataGridView1.DataSource = ent.ogrencinot.ToList();
        }

and i runnig and i see this message:

This exception was originally thrown at this call stack: [External Code]

Inner Exception 1: MySqlException: Table 'eokul.eokul.ogrencinot' doesn't exist

i try too much way. i found another laptop i format it and i install again all this.

and again same error.

really what can i do?

解决方案

1.Close your visual studio project

2.Edit Model1.edmx file with notepad /or what is the name in your project/

3.Replace matches in file, from Schema="okuldb" to Schema=""

4.Save Model1.edmx file

5.Open visual studio project

6.Compile Project

7.Run Application

这篇关于VS 2019和MySQL Entity Framework复制数据库名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆