-1

please tell me how to connect to the database using entity framework

I use workbench to connect and it works well enter image description here

please tell me how these data form a server name to connect via the entity framework enter image description here

2 Answers2

0

Read this

Then try this

Maybe check out these too:

Visual Studio Connect

Last one

Alot can be found from searching stack overflow for your problem

Community
  • 1
  • 1
Pseudo Sudo
  • 1,402
  • 3
  • 16
  • 34
0

When you are creating your DB context (in the constructor) you can define the name of the connection string you'd like to use.

public class MyContext: DbContext
{
    public MyContext() : base("MyContext")
    {
    }
    public MyContext(string connectionString): base(connectionString) 
    {
    }
}

Entity framework will look in your app.config or web.config for a connections tring with the name MyContext alternatively you can directly input the full connection string into the constructor and connect to your database.

For example:

<connectionStrings>
    <add name="MyContext" connectionString="data source=localhost;initial catalog=mydatabasename;integrated security=true;multipleactiveresultsets=True;application name=EntityFramework" providerName="System.Data.SqlClient"/>
</connectionStrings>

how this relates back to you.

All you need to do is put in the server name, the username and password you use to connect to your mysql instance. If you have the correct database providers configured, visual studio will do all the work for you of setting up the connection strings.

Adam Hess
  • 1,396
  • 1
  • 13
  • 28