Closed mooriyami closed 1 year ago
@mooriyami you are very likely mixing different versions of EF Core; check your csproj to make sure all EF-related packages are the same (e.g. 7.0.0-rc.2). If you can't find an issue, please post your csproj here.
Thanks @roji , I checked it, The packages are same. my csproj is :
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>99b34739-414a-487b-8cd9-dc3ffc7fe01d</UserSecretsId>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="BCrypt.Net-Next" Version="4.0.3" />
<PackageReference Include="Inflector.NetStandard" Version="1.2.2" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Cookies" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="7.0.0-rc.2.22476.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.0-rc.2.22472.11" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="7.0.0-rc.2.22472.11" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.17.0" />
<PackageReference Include="Quartz" Version="3.5.0" />
<PackageReference Include="Quartz.NetCore.DependencyInjection" Version="5.0.0" />
<PackageReference Include="RestSharp" Version="108.0.3-alpha.0.5" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
<PackageReference Include="System.Data.OleDb" Version="7.0.0-rc.2.22472.3" />
<PackageReference Include="System.ServiceModel.Duplex" Version="4.10.0" />
<PackageReference Include="System.ServiceModel.Federation" Version="4.10.0" />
<PackageReference Include="System.ServiceModel.Http" Version="4.10.0" />
<PackageReference Include="System.ServiceModel.NetTcp" Version="4.10.0" />
<PackageReference Include="System.ServiceModel.Security" Version="4.10.0" />
</ItemGroup>
</Project>
@mooriyami There is no EF Core provider referenced there, which means some other package is pulling in an old version of the Microsoft.EntityFrameworkCore.SqlServer by a transitive reference.
Thanks @ajcvickers, I had another project with Ef core provider that was referenced in my project but I removed extra parts in the code so I did not no have no PackageReference for that in previous csproj . As you said, I referenced EF Core provider but it does not work and the new csproj is like this:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>99b34739-414a-487b-8cd9-dc3ffc7fe01d</UserSecretsId>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="BCrypt.Net-Next" Version="4.0.3" />
<PackageReference Include="Inflector.NetStandard" Version="1.2.2" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Cookies" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="7.0.0-rc.2.22476.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.0-rc.2.22472.11" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="7.0.0-rc.2.22472.11" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="7.0.0-rc.1.22426.7" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.0-rc.1.22426.7" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer.NetTopologySuite" Version="7.0.0-rc.1.22426.7" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.17.0" />
<PackageReference Include="Quartz" Version="3.5.0" />
<PackageReference Include="Quartz.NetCore.DependencyInjection" Version="5.0.0" />
<PackageReference Include="RestSharp" Version="108.0.3-alpha.0.5" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
<PackageReference Include="System.Data.OleDb" Version="7.0.0-rc.2.22472.3" />
<PackageReference Include="System.ServiceModel.Duplex" Version="4.10.0" />
<PackageReference Include="System.ServiceModel.Federation" Version="4.10.0" />
<PackageReference Include="System.ServiceModel.Http" Version="4.10.0" />
<PackageReference Include="System.ServiceModel.NetTcp" Version="4.10.0" />
<PackageReference Include="System.ServiceModel.Security" Version="4.10.0" />
</ItemGroup>
</Project>
Now you are mixing rc1 and rc2 packages...
Bug
After we upgrade our project to efcore version 7.0.0-rc.2.22472.11, when we call await _dbContext.SaveChangesAsync() to save changes in database, the changes affected database but we have this exception.
Exception
Stack traces
Output
Provider and version information
EF Core version: 7.0.0-rc.2.22472.11 Database provider: Microsoft.EntityFrameworkCore.SqlServer