简体   繁体   中英

.Net Core - Entity Framework - MySQL > UseMysql not found

I am trying to build a simple .NET Core webapi with Entity Framework as ORM and MySQL as database backend.

The problem is that I cannot use the UseMysql method in the ConfigureServices method my Startup class:

VS代码

It looks like I need something more at the using section.

These are the relevant dependencies:

"MySql.Data.EntityFrameworkCore":"7.0.6-ir31",
"Microsoft.EntityFrameworkCore": "1.0.0",
"Microsoft.EntityFrameworkCore.Design": "1.0.0-preview2-final",
"Microsoft.EntityFrameworkCore.Tools":"1.0.0-preview1-final" 

and I've also added this as a tool:

"Microsoft.EntityFrameworkCore.Tools":"1.0.0-preview2-final"

The solution was to add some more usings:

using MySQL.Data.EntityFrameworkCore.Extensions;
using System.ComponentModel.DataAnnotations; 

With these two I was able to compile it.

For me what helped is to add the fully qualified name.

Microsoft.EntityFrameworkCore.MySQLDbContextOptionsExtensions.UseMySQL(....)

Maybe it helps!

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