Skip to content

Commit bf7f526

Browse files
author
David Fallah
committed
Add test to expose issue
1 parent dfb4310 commit bf7f526

2 files changed

Lines changed: 29 additions & 0 deletions

File tree

test/SpatialFocus.EntityFrameworkCore.Extensions.Test/NamingOptionsTest.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ namespace SpatialFocus.EntityFrameworkCore.Extensions.Test
88
using System;
99
using System.Linq;
1010
using Microsoft.EntityFrameworkCore;
11+
using Microsoft.EntityFrameworkCore.ChangeTracking;
1112
using Microsoft.EntityFrameworkCore.Metadata;
1213
using Microsoft.EntityFrameworkCore.Storage;
1314
using SpatialFocus.EntityFrameworkCore.Extensions.Test.Entities;
@@ -88,5 +89,32 @@ public void SetNamingScheme()
8889
Assert.True(findEntityType.GetForeignKeys().All(x => x.GetConstraintName() == NamingScheme.SnakeCase(x.GetDefaultName())));
8990
Assert.True(findEntityType.GetIndexes().All(x => x.GetName() == NamingScheme.SnakeCase(x.GetDefaultName())));
9091
}
92+
93+
[Fact]
94+
public void MultipleProviders()
95+
{
96+
DbContextOptions<ChangeTrackerInConstructorContext> inMemoryOptions = new DbContextOptionsBuilder<ChangeTrackerInConstructorContext>()
97+
.UseInMemoryDatabase(Guid.NewGuid().ToString(), new InMemoryDatabaseRoot())
98+
.Options;
99+
100+
ChangeTrackerInConstructorContext _ = new ChangeTrackerInConstructorContext(inMemoryOptions, EnumLookupOptions.Default, null);
101+
102+
DbContextOptions<ChangeTrackerInConstructorContext> sqliteOptions = new DbContextOptionsBuilder<ChangeTrackerInConstructorContext>()
103+
.UseSqlite("Filename=:memory:")
104+
.Options;
105+
106+
ChangeTrackerInConstructorContext context = new ChangeTrackerInConstructorContext(sqliteOptions, EnumLookupOptions.Default, null);
107+
context.Database.EnsureCreated();
108+
context.Dispose();
109+
}
110+
111+
private class ChangeTrackerInConstructorContext : ProductContext
112+
{
113+
public ChangeTrackerInConstructorContext(DbContextOptions options, EnumLookupOptions enumLookupOptions, NamingOptions namingOptions)
114+
: base(options, enumLookupOptions, namingOptions)
115+
{
116+
ChangeTracker _ = ChangeTracker;
117+
}
118+
}
91119
}
92120
}

test/SpatialFocus.EntityFrameworkCore.Extensions.Test/SpatialFocus.EntityFrameworkCore.Extensions.Test.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
<ItemGroup>
1010
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="3.1.0" />
11+
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="3.1.0" />
1112
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
1213
<PackageReference Include="xunit" Version="2.4.0" />
1314
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />

0 commit comments

Comments
 (0)