9

I would like to ask- is it possible to connect to MySql database in DNX Core 5.0? In my project I need to do web api and I have vNext Class Library project that should connect to MySql database and manipulate the data in this database. But...

I have the newest .net/connector installed. I have downloaded the MySql.Data NuGet package and in references it is added to both- DNX 4.5.1 and Core 5.0 as well. But I get error- functions such as open the connection to my database, execute query etc are not available in DNX Core 5.0. The code is working in Visual Studio 2013 and in DNX 4.5.1 as well. I am not able to find any answer how to connect in DNX Core 5.0 to MySql (neither if it is even possible).

I was advised to downolad the source code of the newest connector/net and copy the code for MySql.Data to new vNext Class Library project and add reference to my Class Library that is supposed to access the database. But I have approx 1600 errors. I was told to solve them one by one. But that seems to be even bigger problem. It looks like it would be possible to solve by adding several references but I cannot find the equivalent reference that would work for DNX Core 5.0. Is this a good approach?

I would appreciate any help. Thank you.

micihime
  • 91
  • 4
  • 3
    You're aware of that you can just remove Core 5.0 from the "frameworks" section in project.json so that you don't need your other dependencies to be Core 5 compliant? Running towards dnx 4.5.1 (which includes all .net versions from and above 4.5.1 , ie. 4.5.1, 4.5.2, 4.6 etc.) should be what most people want unless you need a fully platform independent deployment, which is what Core is meant for. – Trygve Nov 12 '15 at 14:37
  • And you probably don't need EF 7 either, EF 6 with MySQL should work fine, or don't use EF at all (which is what I do). A MicroORM or NHibernate are good alternatives. – Trygve Nov 12 '15 at 14:38

2 Answers2

2

Saldy it's not in EntityFramework 7 yet, my understanding is that they're not prioritizing it for the initial release that's scheduled in January.

Read more: https://github.com/aspnet/EntityFramework/wiki/Using-EF7-in-Traditional-.NET-Applications

muntr
  • 36
  • 2
0

I have a similar question running.

DNXCORE 5.0 and mysql / mariadb

At this moment it is not possible to run MySQL and DNX 5.0! If you want to use it with DNX, you have to fall back on 4.5.1 ( and use mono for Linux environments )

This is because there is no connector available for MySQL. If applicable, you can use postgresql with DNX 5.0 in stead of MySQL/MariaDB

Community
  • 1
  • 1
Rob Van Pamel
  • 734
  • 1
  • 8
  • 23