简体   繁体   中英

Visual Studio QueryFirst Extension

To those, who use QueryFirst ( https://www.codeproject.com/tips/1108776/queryfirst-world-first-implementation-of-the-domin )

How to connect it to a Wampserver MySQL database? I have connected the db to my project with

Connect to Database

in

Server Explorer

But with the Connect icon of QueryFirst I cannot attach my db to Query1.sql.

  1. You will need to create a connection string called QfDefaultConnection in your app or web.config.
  2. specify the ADO provider MySql (providerName="MySql.Data.MySqlClient") are supported. This data source will be used at design time to retrieve the schema. At runtime.
  3. you need to supply a class, QfRuntimeConnection, with a static method GetConnection(). You must supply this class, but you can always manage the connection yourself if you have other ideas. The compiler will show you the way !

Here is a sample for your reference.

https://1drv.ms/u/s!AlvaNEnglADDgQU4I1v9w2nMEIS2

In your app.config, you'll need a connection string like this...

<add name="QfDefaultConnection" connectionString="Server=localhost;Database=dbname;Uid=root;Pwd=Dimosoftware=1;AllowUserVariables=True;" providerName="MySql.Data.MySqlClient"></add>

and code...

using System;
using System.Configuration;
using System.Data;
using MySql.Data.MySqlClient;

namespace YourApp
{
    class QfRuntimeConnection
    {
        public static IDbConnection GetConnection()
        {
            return new MySqlConnection(ConfigurationManager.ConnectionStrings["QfDefaultConnection"].ConnectionString);
        }
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM