我收到此错误,我不知道原因。
我在尝试连接数据库时收到此错误,如下所示:
public MySqlConnection CreateConnection()
{
_sqlConnection = new MySqlConnection(_connectionString);
_sqlConnection.Open(); --in this line i get the error msg
return _sqlConnection;
}
使用MySql.Data和Dapper连接它。我猜一些依赖性缺失或不正确,但我不知道我必须在哪里搜索它。关注我的csproj文件(我知道如果我想使用Dapper,我不需要entityFrameworkcore。它仍然留下并仍然被删除):
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Reference Include="System.Core">
<Private>True</Private>
</Reference>
<PackageReference Include="Dapper">
<Version>1.50.2</Version>
</PackageReference>
<PackageReference Include="IdentityServer4">
<Version>1.5.0</Version>
</PackageReference>
<PackageReference Include="IdentityServer4.AccessTokenValidation">
<Version>1.2.0</Version>
</PackageReference>
<PackageReference Include="IdentityServer4.AspNetIdentity">
<Version>1.0.1</Version>
</PackageReference>
<PackageReference Include="IdentityServer4.EntityFramework">
<Version>1.0.1</Version>
</PackageReference>
<PackageReference Include="Microsoft.AspNetCore">
<Version>1.1.2</Version>
</PackageReference>
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore">
<Version>1.1.1</Version>
</PackageReference>
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore">
<Version>1.1.1</Version>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer">
<Version>1.1.2</Version>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.1" />
<PackageReference Include="Microsoft.NETCore.Portable.Compatibility">
<Version>1.0.1</Version>
</PackageReference>
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="1.1.0" />
</ItemGroup>
<ItemGroup>
<Folder Include="Config" />
<Folder Include="Data\abstract" />
<Folder Include="Data\concrete" />
<Folder Include="Data\Test" />
<Folder Include="docker" />
<Folder Include="Models\test" />
<Folder Include="out\out\out\out\out\out\out\out\out\out\out\out\Views\Home" />
<Folder Include="out\out\out\out\out\out\out\out\out\out\out\out\Views\Shared" />
<Folder Include="out\out\out\out\out\out\out\out\out\out\out\Views\Home" />
<Folder Include="out\out\out\out\out\out\out\out\out\out\out\Views\Shared" />
<Folder Include="out\out\out\out\out\out\out\out\out\out\Views\Home" />
<Folder Include="out\out\out\out\out\out\out\out\out\out\Views\Shared" />
<Folder Include="out\out\out\out\out\out\out\out\out\Views\Home" />
<Folder Include="out\out\out\out\out\out\out\out\out\Views\Shared" />
<Folder Include="out\out\out\out\out\out\out\out\Views\Home" />
<Folder Include="out\out\out\out\out\out\out\out\Views\Shared" />
<Folder Include="out\out\out\out\out\out\out\Views\Home" />
<Folder Include="out\out\out\out\out\out\out\Views\Shared" />
<Folder Include="out\out\out\out\out\Views\Home" />
<Folder Include="out\out\out\out\out\Views\Shared" />
<Folder Include="out\out\out\out\Views\Home" />
<Folder Include="out\out\out\out\Views\Shared" />
<Folder Include="out\out\out\Views\Home" />
<Folder Include="out\out\out\Views\Shared" />
<Folder Include="out\runtimes\unix\lib\netstandard1.6" />
<Folder Include="out\runtimes\win\lib\netstandard1.3" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="1.0.0-msbuild3-final" />
</ItemGroup>
<ItemGroup>
<Reference Include="MySql.Data, Version=1.0.10.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d">
<HintPath>..\..\..\Downloads\mysql-connector-net-1.0.10-noinstall\bin\MySql.Data.dll</HintPath>
</Reference>
</ItemGroup>
</Project>