c# - Trying to get Mysql code first from database to work -


edit: found post , worked, had run win forms:

enable entity framework 6 mysql (c#) in winforms of microsoft visual studio 2013

op--------------------

i have created console c# application

  • when right click on project,
  • goto add new item,
  • i add ado.net entity data model called model1
  • i select mysql connection , hit finish

nothing happens. closes wizard , nothing.

anyone come across problem?

i have installed mysql visaul studio program , have run npm command:

install-package mysql.data.entities 

my app.config looks this:

<?xml version="1.0" encoding="utf-8"?> <configuration>   <configsections>     <section name="entityframework" type="system.data.entity.internal.configfile.entityframeworksection, entityframework, version=6.0.0.0, culture=neutral, publickeytoken=b77a5c561934e089" requirepermission="false" />     <!-- more information on entity framework configuration, visit http://go.microsoft.com/fwlink/?linkid=237468 -->   </configsections>   <startup>     <supportedruntime version="v4.0" sku=".netframework,version=v4.5" />   </startup>   <entityframework>     <providers>       <provider invariantname="mysql.data.mysqlclient" type="mysql.data.mysqlclient.mysqlproviderservices, mysql.data.entity.ef6" />     </providers>   </entityframework>   <system.data>     <dbproviderfactories>       <remove invariant="mysql.data.mysqlclient"></remove>       <add name="mysql data provider" invariant="mysql.data.mysqlclient" description=".net framework data provider mysql" type="mysql.data.mysqlclient.mysqlclientfactory, mysql.data, version=6.8.3.0" />     </dbproviderfactories>   </system.data>   <runtime>     <assemblybinding xmlns="urn:schemas-microsoft-com:asm.v1">       <dependentassembly>         <assemblyidentity name="mysql.data" publickeytoken="c5687fc88969c44d" culture="neutral" />         <bindingredirect oldversion="0.0.0.0-6.8.5.0" newversion="6.8.5.0" />       </dependentassembly>     </assemblybinding>   </runtime> </configuration> 

a connection string needed in order connect database. don't have info there.

assuming installed mysql.data well, try code:

    mysqlconnectionstringbuilder conn_string = new mysqlconnectionstringbuilder(); conn_string.server = "yourserver.com"; conn_string.userid = "youruser"; conn_string.password = "yourpass"; conn_string.database = "yourdatabasename";  using (mysqlconnection conn = new mysqlconnection(conn_string.tostring())) using (mysqlcommand cmd = conn.createcommand()) {    //watch out sql injection vulnerability below      cmd.commandtext = string.format("select * users --just test");      connection.open();      cmd.executenonquery(); } 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -