Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 1 addition & 1 deletion .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: 8.0.x
dotnet-version: 10.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/integration-tests-on-emulator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: 8.0.x
dotnet-version: 10.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/integration-tests-on-production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: 8.0.x
dotnet-version: 10.0.x
- id: 'auth'
uses: 'google-github-actions/auth@v3'
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/samples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: 8.0.x
dotnet-version: 10.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>

<IsPackable>false</IsPackable>

Expand All @@ -19,8 +19,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="8.0.23" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.23">
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="10.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="10.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ public async Task CanUseStringFormat()

var formattedName = await db.Singers
.Where(s => new long[] { singerId }.Contains(s.SingerId))
.Select(s => string.Format("String without formatting"))
.Select(s => string.Format("String without formatting", Array.Empty<object>()))
.FirstOrDefaultAsync();
Assert.Equal("String without formatting", formattedName);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<AssemblyName>SampleRunner</AssemblyName>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand All @@ -24,7 +24,7 @@

<ItemGroup>
<PackageReference Include="Docker.DotNet" Version="3.125.15" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.23">
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="10.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
if (!optionsBuilder.IsConfigured)
{
optionsBuilder
.UseSpanner(_connectionString, _ => SpannerModelValidationConnectionProvider.Instance.EnableDatabaseModelValidation(false), ChannelCredentials.Insecure)

Check warning on line 45 in Google.Cloud.EntityFrameworkCore.Spanner.Tests/AutoGeneratedPrimaryKeyTests/AutoGeneratedPrimaryKeyMockServerTests.cs

View workflow job for this annotation

GitHub Actions / unit-tests

Google.Cloud.EntityFrameworkCore.Spanner.Extensions.Internal.SpannerModelValidationConnectionProvider is an internal API that supports the Entity Framework Core infrastructure and not subject to the same compatibility standards as public APIs. It may be changed or removed without notice in any release.

Check warning on line 45 in Google.Cloud.EntityFrameworkCore.Spanner.Tests/AutoGeneratedPrimaryKeyTests/AutoGeneratedPrimaryKeyMockServerTests.cs

View workflow job for this annotation

GitHub Actions / unit-tests

Google.Cloud.EntityFrameworkCore.Spanner.Extensions.Internal.SpannerModelValidationConnectionProvider is an internal API that supports the Entity Framework Core infrastructure and not subject to the same compatibility standards as public APIs. It may be changed or removed without notice in any release.

Check warning on line 45 in Google.Cloud.EntityFrameworkCore.Spanner.Tests/AutoGeneratedPrimaryKeyTests/AutoGeneratedPrimaryKeyMockServerTests.cs

View workflow job for this annotation

GitHub Actions / integration-tests-on-emulator

Google.Cloud.EntityFrameworkCore.Spanner.Extensions.Internal.SpannerModelValidationConnectionProvider is an internal API that supports the Entity Framework Core infrastructure and not subject to the same compatibility standards as public APIs. It may be changed or removed without notice in any release.

Check warning on line 45 in Google.Cloud.EntityFrameworkCore.Spanner.Tests/AutoGeneratedPrimaryKeyTests/AutoGeneratedPrimaryKeyMockServerTests.cs

View workflow job for this annotation

GitHub Actions / integration-tests-on-emulator

Google.Cloud.EntityFrameworkCore.Spanner.Extensions.Internal.SpannerModelValidationConnectionProvider is an internal API that supports the Entity Framework Core infrastructure and not subject to the same compatibility standards as public APIs. It may be changed or removed without notice in any release.

Check warning on line 45 in Google.Cloud.EntityFrameworkCore.Spanner.Tests/AutoGeneratedPrimaryKeyTests/AutoGeneratedPrimaryKeyMockServerTests.cs

View workflow job for this annotation

GitHub Actions / run-samples

Google.Cloud.EntityFrameworkCore.Spanner.Extensions.Internal.SpannerModelValidationConnectionProvider is an internal API that supports the Entity Framework Core infrastructure and not subject to the same compatibility standards as public APIs. It may be changed or removed without notice in any release.

Check warning on line 45 in Google.Cloud.EntityFrameworkCore.Spanner.Tests/AutoGeneratedPrimaryKeyTests/AutoGeneratedPrimaryKeyMockServerTests.cs

View workflow job for this annotation

GitHub Actions / run-samples

Google.Cloud.EntityFrameworkCore.Spanner.Extensions.Internal.SpannerModelValidationConnectionProvider is an internal API that supports the Entity Framework Core infrastructure and not subject to the same compatibility standards as public APIs. It may be changed or removed without notice in any release.

Check warning on line 45 in Google.Cloud.EntityFrameworkCore.Spanner.Tests/AutoGeneratedPrimaryKeyTests/AutoGeneratedPrimaryKeyMockServerTests.cs

View workflow job for this annotation

GitHub Actions / integration-tests-on-prod

Google.Cloud.EntityFrameworkCore.Spanner.Extensions.Internal.SpannerModelValidationConnectionProvider is an internal API that supports the Entity Framework Core infrastructure and not subject to the same compatibility standards as public APIs. It may be changed or removed without notice in any release.

Check warning on line 45 in Google.Cloud.EntityFrameworkCore.Spanner.Tests/AutoGeneratedPrimaryKeyTests/AutoGeneratedPrimaryKeyMockServerTests.cs

View workflow job for this annotation

GitHub Actions / integration-tests-on-prod

Google.Cloud.EntityFrameworkCore.Spanner.Extensions.Internal.SpannerModelValidationConnectionProvider is an internal API that supports the Entity Framework Core infrastructure and not subject to the same compatibility standards as public APIs. It may be changed or removed without notice in any release.
.UseLazyLoadingProxies();
}
}
Expand All @@ -63,7 +63,7 @@
{
var sql = $"SELECT `i`.`InvoiceId`, `i`.`Description`{Environment.NewLine}" +
$"FROM `Invoices` AS `i`{Environment.NewLine}" +
$"WHERE `i`.`InvoiceId` = @__p_0{Environment.NewLine}" +
$"WHERE `i`.`InvoiceId` = @p{Environment.NewLine}" +
$"LIMIT 1";
_fixture.SpannerMock.AddOrUpdateStatementResult(sql, StatementResult.CreateResultSet(
new List<Tuple<V1.Type, string>>(),
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ public async Task UpdateSinger_SelectsFullName()
// Setup results.
var selectSingerSql = AddFindSingerResult($"SELECT `s`.`SingerId`, `s`.`BirthDate`, `s`.`FirstName`, " +
$"`s`.`FullName`, `s`.`LastName`, `s`.`Picture`{Environment.NewLine}FROM `Singers` AS `s`{Environment.NewLine}" +
$"WHERE `s`.`SingerId` = @__p_0{Environment.NewLine}LIMIT 1");
$"WHERE `s`.`SingerId` = @p{Environment.NewLine}LIMIT 1");
var selectFullNameSql = AddSelectSingerFullNameResult("Alice Pieterson-Morrison", 0);

await using var db = new MockServerSampleDbContextUsingMutations(ConnectionString);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>

<IsPackable>false</IsPackable>

Expand All @@ -18,11 +18,11 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.23">
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="10.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="8.0.23" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="10.0.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
<PackageReference Include="xunit" Version="2.9.3" />
<PackageReference Include="Xunit.Combinatorial" Version="1.7.31" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@
using Microsoft.EntityFrameworkCore.Migrations;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Google.Cloud.EntityFrameworkCore.Spanner.Extensions;
using Google.Cloud.Spanner.V1;
using Xunit;

namespace Google.Cloud.EntityFrameworkCore.Spanner.Tests.MigrationTests
Expand Down Expand Up @@ -58,6 +60,14 @@ public void TestMigrateUsesDdlBatch()
using var db = new MockMigrationSampleDbContext(ConnectionString);
db.Database.Migrate();

var requests = _fixture.SpannerMock.Requests.ToList();
// There is one BatchDmlRequest per migration.
var batchDmlRequests = requests.OfType<ExecuteBatchDmlRequest>();
Assert.Equal(2, batchDmlRequests.Count());
// Each BatchDmlRequest is executed as a separate transaction.
var commitRequests = requests.OfType<CommitRequest>().ToList();
Assert.Equal(2, commitRequests.Count);

Assert.Collection(_fixture.DatabaseAdminMock.Requests,
// The initial request will create an empty database and then create the migrations history table.
request => Assert.IsType<CreateDatabaseRequest>(request),
Expand All @@ -66,7 +76,7 @@ public void TestMigrateUsesDdlBatch()
var update = request as UpdateDatabaseDdlRequest;
Assert.NotNull(update);
Assert.Collection(update.Statements,
sql => Assert.StartsWith("CREATE TABLE `EFMigrationsHistory`", sql)
sql => Assert.StartsWith("CREATE TABLE IF NOT EXISTS `EFMigrationsHistory`", sql)
);
},
// Each migration will be executed as a separate DDL batch.
Expand Down Expand Up @@ -113,7 +123,7 @@ public async Task TestStartMigrateAsync()
var formattedVersion = $"{version.Major}.{version.Minor}.{version.Build}";
_fixture.SpannerMock.AddOrUpdateStatementResult("SELECT 1", StatementResult.CreateSelect1ResultSet());
_fixture.SpannerMock.AddOrUpdateStatementResult(
"SELECT EXISTS(SELECT 1 FROM information_schema.tables WHERE table_catalog = '' and table_schema = '' and table_name = '''EFMigrationsHistory''')",
"SELECT EXISTS(SELECT 1 FROM information_schema.tables WHERE table_schema = '' AND table_name = 'EFMigrationsHistory')",
StatementResult.CreateSelectTrueResultSet());
_fixture.SpannerMock.AddOrUpdateStatementResult($"SELECT `MigrationId`, `ProductVersion`{Environment.NewLine}" +
$"FROM `EFMigrationsHistory`{Environment.NewLine}" +
Expand All @@ -138,6 +148,15 @@ public async Task TestStartMigrateAsync()
Assert.Collection(_fixture.DatabaseAdminMock.Requests,
// Each migration will be executed as a separate DDL batch.
request =>
{
var update = request as UpdateDatabaseDdlRequest;
Assert.NotNull(update);
Assert.Collection(update.Statements,
// Entity Framework 10 executes this regardless whether database provider has already told it
// that the table exists or not.
sql => Assert.StartsWith("CREATE TABLE IF NOT EXISTS `EFMigrationsHistory`", sql)
);
}, request =>
{
var update = request as UpdateDatabaseDdlRequest;
Assert.NotNull(update);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public async Task TestEntity_ConvertValuesWithoutPrecisionLossOrOverflow_Succeed
{
var sql = $"SELECT `t`.`Id`, `t`.`ByteCol`, `t`.`DecimalCol`, `t`.`FloatCol`" +
$"{Environment.NewLine}FROM `TestEntities` AS `t`{Environment.NewLine}" +
$"WHERE `t`.`Id` = @__p_0{Environment.NewLine}LIMIT 1";
$"WHERE `t`.`Id` = @p{Environment.NewLine}LIMIT 1";
_fixture.SpannerMock.AddOrUpdateStatementResult(sql, StatementResult.CreateResultSet(
new List<Tuple<V1.Type, string>>
{
Expand Down Expand Up @@ -105,7 +105,7 @@ public async Task TestEntity_ConvertValuesWithByteOverflow_Fails()
{
var sql = $"SELECT `t`.`Id`, `t`.`ByteCol`, `t`.`DecimalCol`, `t`.`FloatCol`" +
$"{Environment.NewLine}FROM `TestEntities` AS `t`{Environment.NewLine}" +
$"WHERE `t`.`Id` = @__p_0{Environment.NewLine}LIMIT 1";
$"WHERE `t`.`Id` = @p{Environment.NewLine}LIMIT 1";
_fixture.SpannerMock.AddOrUpdateStatementResult(sql, StatementResult.CreateResultSet(
new List<Tuple<V1.Type, string>>
{
Expand All @@ -129,7 +129,7 @@ public async Task TestEntity_ConvertValuesWithFloatOverflow_Succeeds()
{
var sql = $"SELECT `t`.`Id`, `t`.`ByteCol`, `t`.`DecimalCol`, `t`.`FloatCol`" +
$"{Environment.NewLine}FROM `TestEntities` AS `t`{Environment.NewLine}" +
$"WHERE `t`.`Id` = @__p_0{Environment.NewLine}LIMIT 1";
$"WHERE `t`.`Id` = @p{Environment.NewLine}LIMIT 1";
_fixture.SpannerMock.AddOrUpdateStatementResult(sql, StatementResult.CreateResultSet(
new List<Tuple<V1.Type, string>>
{
Expand All @@ -155,7 +155,7 @@ public async Task TestEntity_ConvertValuesWithDecimalOverflow_Fails()
{
var sql = $"SELECT `t`.`Id`, `t`.`ByteCol`, `t`.`DecimalCol`, `t`.`FloatCol`" +
$"{Environment.NewLine}FROM `TestEntities` AS `t`{Environment.NewLine}" +
$"WHERE `t`.`Id` = @__p_0{Environment.NewLine}LIMIT 1";
$"WHERE `t`.`Id` = @p{Environment.NewLine}LIMIT 1";
_fixture.SpannerMock.AddOrUpdateStatementResult(sql, StatementResult.CreateResultSet(
new List<Tuple<V1.Type, string>>
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"$schema": "https://xunit.net/schema/current/xunit.runner.schema.json",
"parallelizeTestCollections": true
"parallelizeTestCollections": true,
"diagnosticMessages": true
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ public static IServiceCollection AddEntityFrameworkSpanner(this IServiceCollecti
{
GaxPreconditions.CheckNotNull(serviceCollection, nameof(serviceCollection));

var builder = new EntityFrameworkRelationalServicesBuilder(serviceCollection)
var builder = new EntityFrameworkRelationalServicesBuilder(serviceCollection);
builder
.TryAdd<LoggingDefinitions, SpannerLoggingDefinitions>()
.TryAdd<IDatabaseProvider, DatabaseProvider<SpannerOptionsExtension>>()
.TryAdd<IRelationalTypeMappingSource, SpannerTypeMappingSource>()
Expand All @@ -59,6 +60,7 @@ public static IServiceCollection AddEntityFrameworkSpanner(this IServiceCollecti
.TryAdd<IBatchExecutor, SpannerBatchExecutor>()
.TryAdd<IModificationCommandBatchFactory, SpannerModificationCommandBatchFactory>()
.TryAdd<IQuerySqlGeneratorFactory, SpannerQuerySqlGeneratorFactory>()
.TryAdd<IRelationalSqlTranslatingExpressionVisitorFactory, SpannerSqlTranslatingExpressionVisitorFactory>()
.TryAdd<IMethodCallTranslatorProvider, SpannerMethodCallTranslatorProvider>()
.TryAdd<IMemberTranslatorProvider, SpannerMemberTranslatorProvider>()
.TryAdd<IRelationalConnection>(p => p.GetService<ISpannerRelationalConnection>())
Expand All @@ -73,6 +75,8 @@ public static IServiceCollection AddEntityFrameworkSpanner(this IServiceCollecti
.TryAddProviderSpecificServices(b => b
.TryAddScoped<ISpannerRelationalConnection, SpannerRelationalConnection>()
);
// Add Core services after the Spanner-specific services to let the
// Spanner-specific services take precedence.
builder.TryAddCoreServices();
serviceCollection.AddEntityFrameworkProxies();
return serviceCollection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<Description>Google Cloud Spanner database provider for Entity Framework Core.</Description>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<AssemblyName>Google.Cloud.EntityFrameworkCore.Spanner</AssemblyName>
<RootNamespace>Google.Cloud.EntityFrameworkCore.Spanner</RootNamespace>
<LangVersion>latest</LangVersion>
Expand All @@ -21,9 +21,9 @@
<ItemGroup>
<PackageReference Include="Google.Cloud.Spanner.Data" Version="5.12.0"/>
<PackageReference Include="JetBrains.Annotations" Version="2024.3.0" PrivateAssets="All"/>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.23" PrivateAssets="All"/>
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="8.0.23"/>
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="8.0.23"/>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="10.0.2" PrivateAssets="All"/>
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="10.0.2"/>
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="10.0.2"/>
<PackageReference Include="OpenTelemetry.Api" Version="1.15.0"/>
<PackageReference Include="System.Text.Json" Version="8.0.6"/>
</ItemGroup>
Expand Down
Loading
Loading