Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
789 views
in Technique[技术] by (71.8m points)

c# - VS 2019 and MySQL Entity Framework duplicate database name

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...