Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
<PackageVersion Include="FirebirdSql.Data.FirebirdClient" Version="10.3.4" />
<PackageVersion Include="GitHubActionsTestLogger" Version="2.4.1" />
<PackageVersion Include="Iesi.Collections" Version="4.1.1" />
<PackageVersion Include="linq2db.SqlServer" Version="5.4.1.9" />
<PackageVersion Include="linq2db" Version="6.2.1" />
<PackageVersion Include="linq2db.SqlServer" Version="6.2.1" />
<PackageVersion Include="Microsoft.Data.SqlClient" Version="6.1.4" />
<PackageVersion Include="Microsoft.Data.Sqlite" Version="10.0.2" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.SqlServer" Version="10.0.2" />
Expand Down
103 changes: 103 additions & 0 deletions LINQ2DB_V6_UPGRADE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# linq2db.SqlServer v6 Upgrade Summary

## Overview

This document summarizes the changes required to upgrade from `linq2db.SqlServer` version 5.4.1.9 to version 6.2.1.

## Breaking Changes

### linq2db.SqlServer Package Structure Change

In **linq2db v6**, the `linq2db.SqlServer` package underwent a significant architectural change:

- **v5.x and earlier**: The `linq2db.SqlServer` package included both T4 scaffolding templates AND the runtime library (`linq2db`) as a transitive dependency.
- **v6.x**: The `linq2db.SqlServer` package is now a **template-only package** containing only T4 scaffolding templates. It no longer includes the runtime library as a dependency.

This means that projects upgrading to v6 must explicitly reference the `linq2db` runtime package.

## Required Changes

### 1. Add linq2db Runtime Package

**File: `Directory.Packages.props`**

Added explicit reference to the `linq2db` runtime package:

```xml
<PackageVersion Include="linq2db" Version="6.2.1" />
<PackageVersion Include="linq2db.SqlServer" Version="6.2.1" />
```

### 2. Update Project References

**File: `benchmarks/Dapper.Tests.Performance/Dapper.Tests.Performance.csproj`**

Added explicit package reference to the runtime library:

```xml
<PackageReference Include="linq2db" />
<PackageReference Include="linq2db.SqlServer" />
```

## Why This Change Was Necessary

Without the explicit `linq2db` package reference, the project fails to build with errors such as:

```
error CS0246: The type or namespace name 'LinqToDB' could not be found
(are you missing a using directive or an assembly reference?)
```

This occurs because:
1. The code uses types from the `LinqToDB` namespace (e.g., `DataConnection`, `ILinqToDBSettings`, `ITable<T>`)
2. These types are provided by the `linq2db` runtime package
3. In v6, `linq2db.SqlServer` no longer brings in the runtime package automatically

## Affected Code

The following files use linq2db runtime types and require the `linq2db` package:

- `benchmarks/Dapper.Tests.Performance/Benchmarks.Linq2DB.cs`
- `benchmarks/Dapper.Tests.Performance/Linq2DB/Linq2DBContext.cs`
- `benchmarks/Dapper.Tests.Performance/Linq2DB/Linq2DbSettings.cs`
- `benchmarks/Dapper.Tests.Performance/Linq2DB/ConnectionStringSettings.cs`
- `benchmarks/Dapper.Tests.Performance/Post.cs`

## Target Frameworks

The changes support all project target frameworks:
- .NET Framework 4.6.2 (net462)
- .NET 8.0 (net8.0)
- .NET 10.0 (net10.0)

## New Features in v6

According to the release notes, linq2db v6 includes:

- .NET 10 support
- Support for new .NET 6-10 LINQ operators: `CountBy`, `Index`, `MaxBy`, `MinBy`, `ExceptBy`, `UnionBy`, `IntersectBy`
- Improved translation of aggregate and window functions
- `string.Join` translation support
- Various SQL generation improvements
- Enhanced support for SQL Server 2025 VECTOR types

## Verification

The upgrade has been verified by:
1. Successful restoration of all NuGet packages
2. Successful compilation for all target frameworks (net462, net8.0, net10.0)
3. Zero build warnings or errors

## Migration Guide for Other Projects

If you have other projects using `linq2db.SqlServer` and are upgrading to v6:

1. Add the `linq2db` package to your package dependencies with the same version as `linq2db.SqlServer`
2. Add a `PackageReference` to `linq2db` in your project file
3. Rebuild and verify compilation

## References

- [linq2db v6.0.0 Release Notes](https://github.com/linq2db/linq2db/releases/tag/v6.0.0)
- [linq2db v6.2.1 Release Notes](https://github.com/linq2db/linq2db/releases/tag/v6.2.1)
- [linq2db Documentation](https://linq2db.github.io/)
8 changes: 6 additions & 2 deletions benchmarks/Dapper.Tests.Performance/Benchmarks.Linq2DB.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
using System.Linq;
using Dapper.Tests.Performance.Linq2Db;
using LinqToDB;
using LinqToDB.Configuration;
using LinqToDB.Data;
using LinqToDB.DataProvider.SqlServer;
using System.ComponentModel;

namespace Dapper.Tests.Performance
Expand All @@ -20,8 +22,10 @@ public class LinqToDBBenchmarks : BenchmarkBase // note To not 2 because the "2"
public void Setup()
{
BaseSetup();
DataConnection.DefaultSettings = new Linq2DBSettings(_connection.ConnectionString);
_dbContext = new Linq2DBContext();
// Use modern DataOptions pattern for linq2db v6
var options = new DataOptions()
.UseSqlServer(_connection.ConnectionString);
_dbContext = new Linq2DBContext(options);
}

[Benchmark(Description = "First")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<PackageReference Include="DevExpress.Xpo" />
<PackageReference Include="EntityFramework" VersionOverride="6.5.1" />
<PackageReference Include="FirebirdSql.Data.FirebirdClient" />
<PackageReference Include="linq2db" />
<PackageReference Include="linq2db.SqlServer" />
<PackageReference Include="MySqlConnector" />
<PackageReference Include="NHibernate" />
Expand Down

This file was deleted.

5 changes: 5 additions & 0 deletions benchmarks/Dapper.Tests.Performance/Linq2DB/Linq2DBContext.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
using LinqToDB;
using LinqToDB.Configuration;

namespace Dapper.Tests.Performance.Linq2Db
{
public class Linq2DBContext : LinqToDB.Data.DataConnection
{
public Linq2DBContext(DataOptions options) : base(options)
{
}

public ITable<Post> Posts => this.GetTable<Post>();
}
}
34 changes: 0 additions & 34 deletions benchmarks/Dapper.Tests.Performance/Linq2DB/Linq2DbSettings.cs

This file was deleted.