borisdj / EFCore.BulkExtensions

Entity Framework EF Core efcore Bulk Batch Extensions with BulkCopy in .Net for Insert Update Delete Read (CRUD), Truncate and SaveChanges operations on SQL Server, PostgreSQL, MySQL, SQLite

Home Page:https://codis.tech/efcorebulk

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

System.IO.FileNotFoundException: Could not load file or assembly 'System.Data.SqlClient, Version=4.6.1.3

slav4ik51493 opened this issue · comments

Hey
I have a some problem with this library when try to deploy to remote hosting.
On local it's working perfectly locally with Debug/Release modes.

My publish profile:

<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
  <PropertyGroup>
    <DeleteExistingFiles>false</DeleteExistingFiles>
    <ExcludeApp_Data>false</ExcludeApp_Data>
    <LaunchSiteAfterPublish>true</LaunchSiteAfterPublish>
    <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
    <LastUsedPlatform>Any CPU</LastUsedPlatform>
    <PublishProvider>FileSystem</PublishProvider>
    <PublishUrl>bin\Release\net7.0\publish\</PublishUrl>
    <WebPublishMethod>FileSystem</WebPublishMethod>
    <_TargetId>Folder</_TargetId>
    <SiteUrlToLaunchAfterPublish />
    <TargetFramework>net7.0</TargetFramework>
    <ProjectGuid>8696b151-48ef-4d59-a010-1688453a93cc</ProjectGuid>
    <SelfContained>false</SelfContained>
  </PropertyGroup>
</Project>

Then I'm copying all files by FTP to my server.
My application is starting without any issue, then in background process running some synchronization which using this library.
And I see in logs next:

System.IO.FileNotFoundException: Could not load file or assembly 'System.Data.SqlClient, Version=4.6.1.3, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
File name: 'System.Data.SqlClient, Version=4.6.1.3, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
   at EFCore.BulkExtensions.SqlAdapters.SqlServer.SqlServerAdapter.InnerGetDataTable[T](DbContext context, Type& type, IEnumerable`1 entities, TableInfo tableInfo)
   at EFCore.BulkExtensions.SqlAdapters.SqlServer.SqlServerAdapter.GetDataTable[T](DbContext context, Type type, IEnumerable`1 entities, SqlBulkCopy sqlBulkCopy, TableInfo tableInfo)
   at EFCore.BulkExtensions.SqlAdapters.SqlServer.SqlServerAdapter.InsertAsync[T](DbContext context, Type type, IEnumerable`1 entities, TableInfo tableInfo, Action`1 progress, Boolean isAsync, CancellationToken cancellationToken)
   at EFCore.BulkExtensions.SqlAdapters.SqlServer.SqlServerAdapter.InsertAsync[T](DbContext context, Type type, IEnumerable`1 entities, TableInfo tableInfo, Action`1 progress, Boolean isAsync, CancellationToken cancellationToken)
   at EFCore.BulkExtensions.SqlAdapters.SqlServer.SqlServerAdapter.InsertAsync[T](DbContext context, Type type, IEnumerable`1 entities, TableInfo tableInfo, Action`1 progress, Boolean isAsync, CancellationToken cancellationToken)
   at EFCore.BulkExtensions.SqlAdapters.SqlServer.SqlServerAdapter.Insert[T](DbContext context, Type type, IEnumerable`1 entities, TableInfo tableInfo, Action`1 progress)
   at EFCore.BulkExtensions.SqlAdapters.SqlServer.SqlServerAdapter.MergeAsync[T](DbContext context, Type type, IEnumerable`1 entities, TableInfo tableInfo, OperationType operationType, Action`1 progress, Boolean isAsync, CancellationToken cancellationToken)
   at EFCore.BulkExtensions.SqlAdapters.SqlServer.SqlServerAdapter.MergeAsync[T](DbContext context, Type type, IEnumerable`1 entities, TableInfo tableInfo, OperationType operationType, Action`1 progress, Boolean isAsync, CancellationToken cancellationToken)
   at EFCore.BulkExtensions.SqlAdapters.SqlServer.SqlServerAdapter.Merge[T](DbContext context, Type type, IEnumerable`1 entities, TableInfo tableInfo, OperationType operationType, Action`1 progress)
   at EFCore.BulkExtensions.SqlBulkOperation.Merge[T](DbContext context, Type type, IEnumerable`1 entities, TableInfo tableInfo, OperationType operationType, Action`1 progress)
   at EFCore.BulkExtensions.DbContextBulkTransactionGraphUtil.ExecuteWithGraphAsync(DbContext context, IEnumerable`1 entities, OperationType operationType, BulkConfig bulkConfig, Action`1 progress, Boolean isAsync, CancellationToken cancellationToken)
   at EFCore.BulkExtensions.DbContextBulkTransactionGraphUtil.ExecuteWithGraphAsync(DbContext context, IEnumerable`1 entities, OperationType operationType, BulkConfig bulkConfig, Action`1 progress, Boolean isAsync, CancellationToken cancellationToken)
   at EFCore.BulkExtensions.DbContextBulkTransactionGraphUtil.ExecuteWithGraph(DbContext context, IEnumerable`1 entities, OperationType operationType, BulkConfig bulkConfig, Action`1 progress)
   at EFCore.BulkExtensions.DbContextBulkTransaction.Execute[T](DbContext context, Type type, IEnumerable`1 entities, OperationType operationType, BulkConfig bulkConfig, Action`1 progress)
   at EFCore.BulkExtensions.DbContextBulkExtensions.BulkInsertOrUpdateOrDelete[T](DbContext context, IEnumerable`1 entities, Action`1 bulkAction, Action`1 progress, Type type)
   at AutoTools.Repository.Repositories.Implementation.SparePartRepository.InsertAllSpareParts(List`1 sparePartsExcel) in C:\Users\Vyacheslav\source\repos\autotools54\AutoTools.Repository\Repositories\Implementation\SparePartRepository.cs:line 31

I've analyzed NuGet references, but I didn't see that System.Data.SqlClient, Version=4.6.1.3 necessary somewhere.
And I couldn't install it, because VS is saying this:

NU1605: Warning As Error: Detected package downgrade: System.Data.SqlClient from 4.8.3 to 4.6.1. Reference the package directly from the project to select a different version. 
 AutoTools.Repository -> EFCore.BulkExtensions.SqlServer 7.0.0 -> EntityFrameworkCore.SqlServer.HierarchyId 4.0.0 -> EntityFrameworkCore.SqlServer.HierarchyId.Abstractions 4.0.0 -> dotMorten.Microsoft.SqlServer.Types 1.5.0 -> System.Data.SqlClient (>= 4.8.3) 
 AutoTools.Repository -> System.Data.SqlClient (>= 4.6.1)
Package restore failed. Rolling back package changes for 'AutoTools.Repository'.

Sorry, my bad
Don't sync runtimes and refs folders to my hosting.

Glad you solved it.