0

Visual Studio 17がインストールされたばかりで、mysqlをデータベースとして使用してWebAPIを開発したいとします。Pomelo.EntityFrameworkCore.MysqlエラーDBContextOptionsBuilderにUseMyQLの定義がありません

マイcsproj:

<Project Sdk="Microsoft.NET.Sdk.Web"> 

    <PropertyGroup> 
    <TargetFramework>netcoreapp1.1</TargetFramework> 
    </PropertyGroup> 

    <ItemGroup> 
    <Folder Include="wwwroot\" /> 
    </ItemGroup> 
    <ItemGroup> 
    <PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.0.0" /> 
    <PackageReference Include="Microsoft.AspNetCore" Version="1.1.1" /> 
    <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.2" /> 
    <PackageReference Include="Microsoft.EntityFrameworkCore" Version="1.1.1" /> 
    <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.1" /> 
    <PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="1.1.1" /> 
    </ItemGroup> 
    <ItemGroup> 
    <DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="1.0.0" /> 
    </ItemGroup> 

</Project> 

私はPomelo.EntityFrameworkCore.MysqlをインストールNuGetパッケージマネージャから。

マイaspsettings.json:ConfigureServices内部の私のstrtup.csで

{ 
    "ConnectionStrings": { 
    "MysqlConnection": "server=localhost;userid=root;pwd=root;port=3306;database=aspnet;sslmode=none;" 
    }, 
    "Logging": { 
    "IncludeScopes": false, 
    "LogLevel": { 
     "Default": "Warning" 
    } 
    } 
} 

()私が持っている:

services.AddDbContext<WebAPIDataContext>(options => 
      { 
       options.UseMySQL(Configuration.GetConnectionString("MysqlConnection")); } 
      ); 
services.AddMvc(); 
services.AddScoped<IProfileRepository, ProfileRepository>(); 

しかし、それは私にDBContextOptionsBuilder does not contain a definition for UseMyQLエラーを与えています。それはなぜですか?

答えて

0

私はそれを変更:

// Add framework services. 
      services.AddDbContext<WebAPIDataContext>(options => 
      { 
       options.UseMySql(Configuration.GetConnectionString("MysqlConnection")); 
      }); 
関連する問題