xUnit InMemoryDatabase Test failure: InvalidOperationException











up vote
2
down vote

favorite
1












I run Unit-Tests on TFS in a CI environment, today it failed with the following exception:



Error:
System.InvalidOperationException : Operations that change non-concurrent collections must have exclusive access. A concurrent update was performed on this collection and corrupted its state. The collection's state is no longer correct.
Stacktrace:
at System.Collections.Generic.Dictionary`2.FindEntry(TKey key)
at System.Collections.Generic.Dictionary`2.TryGetValue(TKey key, TValue& value)
at Microsoft.EntityFrameworkCore.Metadata.Internal.Model.GetDisplayName(Type type)
at Microsoft.EntityFrameworkCore.Metadata.Internal.Model.FindEntityType(Type type)
at Microsoft.EntityFrameworkCore.Query.ExpressionVisitors.Internal.EntityEqualityRewritingExpressionVisitor.RewriteEntityEquality(ExpressionType nodeType, Expression left, Expression right)
at Microsoft.EntityFrameworkCore.Query.ExpressionVisitors.Internal.EntityEqualityRewritingExpressionVisitor.VisitBinary(BinaryExpression binaryExpression)
at System.Linq.Expressions.BinaryExpression.Accept(ExpressionVisitor visitor)
at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)
at System.Linq.Expressions.ExpressionVisitor.VisitBinary(BinaryExpression node)
at Microsoft.EntityFrameworkCore.Query.ExpressionVisitors.Internal.EntityEqualityRewritingExpressionVisitor.VisitBinary(BinaryExpression binaryExpression)
at System.Linq.Expressions.BinaryExpression.Accept(ExpressionVisitor visitor)
at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)
at Remotion.Linq.Clauses.WhereClause.TransformExpressions(Func`2 transformation)
at Remotion.Linq.QueryModel.TransformExpressions(Func`2 transformation)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryOptimizer.Optimize(QueryCompilationContext queryCompilationContext, QueryModel queryModel)
at Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor.OptimizeQueryModel(QueryModel queryModel, Boolean asyncQuery)
at Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor.CreateQueryExecutor[TResult](QueryModel queryModel)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.CompileQueryCore[TResult](Expression query, IQueryModelGenerator queryModelGenerator, IDatabase database, IDiagnosticsLogger`1 logger, Type contextType)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.<>c__DisplayClass13_0`1.<Execute>b__0()
at Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddQueryCore[TFunc](Object cacheKey, Func`1 compiler)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.Execute[TResult](Expression query)
at System.Linq.Queryable.Any[TSource](IQueryable`1 source)
at ModelNamespace.SomeRepository.TestMethod()
at TestNamespace.SomeRepositoryTest.TestMethod_Test()


After that I started the same build on the same commit again and it succeeded. Odd isn't it?



How the Tests are built up



To set up InMemoryDatabases, we use the following helper Class:



public class DbContextTestHelper
{
public static DbContextOptions<CustomContext> PrepareData(Action<CustomContext> createData)
{
var options = CreateDbContextOptions();
SaveData(options, createData);
return options;
}

private static void SaveData(DbContextOptions<CustomContext> options, Action<CustomContext> createData)
{
// Insert seed data into the database using one instance of the context
using (var context = new CustomContext(options))
{
createData.Invoke(context);
context.SaveChanges();
}
}

private static DbContextOptions<CustomContext> CreateDbContextOptions()
{
return new DbContextOptionsBuilder<CustomContext>()
.UseInMemoryDatabase(Guid.NewGuid()
.ToString()) //Database with same name gets reused, so let's isolate the tests from each other...
.Options;
}
}


So now we have many Tests we build up like this:



public class SomeRepositoryTest
{
[Fact]
public async Task TestMethod_Test()
{
var options = DbContextTestHelper.PrepareData(context =>
{
// do some initialisation
});
// Use a clean instance of the context to run the test
using (var context = new CustomContext(options))
{
var testee = new SomeRepository(context);
await testee.TestMethod(); // InvalidOperationException from above
// Assert something
}
}
}


Of course there are many cases where we create those DbContextOptions<CustomContext> and naturally they run parallel because of the built-in functionality that xUnit provides (yes of course not in the same class but for many test classes).



My Question



As far as I can tell there are few possibilities of why this can sometimes cause an exception:




  • the GUID's generated to ensure different instances of InMemoryDatabases are duplicates. However I'd rather not believe this.

  • there is a bug in the InMememory Database System

  • We are using InMemoryDatabases wrong


Do you know what's going on?



Edit 1:



As Requested, here's the TestMethod() where System.Linq.Queryable.Any[TSource](IQueryable'1 source) gets called.



    public void TestMethod(SomeObject someObject, List<DateTime> dates, bool someOption)
{
var res = _dbContext.SomeSet.Where(o =>
o.SomeObject.Equals(someObject) && dates.Contains(o.DateTime) && o.SomeOption == someOption);
if (res.Any()) // at System.Linq.Queryable.Any[TSource](IQueryable`1 source)
{
_dbContext.SomeSet.RemoveRange(res);
}
}









share|improve this question
























  • This appears to be an issue in EntityFrameworkCore github.com/IdentityServer/IdentityServer4/issues/2453. One suggested fix is to use ConcurrentDictionary
    – obl
    yesterday












  • @obl the point is, that im not at all accessing any dictionary. I only have an InMemoryDB and a DbContext. There are only DbSet<T> which I access. So im not really able to change this behavior.
    – LuckyLikey
    yesterday










  • Gotcha. Can you find the System.Linq.Queryable.Any[TSource](IQueryable`1 source) query mentioned in the stack trace and post it?
    – obl
    14 hours ago












  • @obl added it. hope it helps
    – LuckyLikey
    52 mins ago















up vote
2
down vote

favorite
1












I run Unit-Tests on TFS in a CI environment, today it failed with the following exception:



Error:
System.InvalidOperationException : Operations that change non-concurrent collections must have exclusive access. A concurrent update was performed on this collection and corrupted its state. The collection's state is no longer correct.
Stacktrace:
at System.Collections.Generic.Dictionary`2.FindEntry(TKey key)
at System.Collections.Generic.Dictionary`2.TryGetValue(TKey key, TValue& value)
at Microsoft.EntityFrameworkCore.Metadata.Internal.Model.GetDisplayName(Type type)
at Microsoft.EntityFrameworkCore.Metadata.Internal.Model.FindEntityType(Type type)
at Microsoft.EntityFrameworkCore.Query.ExpressionVisitors.Internal.EntityEqualityRewritingExpressionVisitor.RewriteEntityEquality(ExpressionType nodeType, Expression left, Expression right)
at Microsoft.EntityFrameworkCore.Query.ExpressionVisitors.Internal.EntityEqualityRewritingExpressionVisitor.VisitBinary(BinaryExpression binaryExpression)
at System.Linq.Expressions.BinaryExpression.Accept(ExpressionVisitor visitor)
at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)
at System.Linq.Expressions.ExpressionVisitor.VisitBinary(BinaryExpression node)
at Microsoft.EntityFrameworkCore.Query.ExpressionVisitors.Internal.EntityEqualityRewritingExpressionVisitor.VisitBinary(BinaryExpression binaryExpression)
at System.Linq.Expressions.BinaryExpression.Accept(ExpressionVisitor visitor)
at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)
at Remotion.Linq.Clauses.WhereClause.TransformExpressions(Func`2 transformation)
at Remotion.Linq.QueryModel.TransformExpressions(Func`2 transformation)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryOptimizer.Optimize(QueryCompilationContext queryCompilationContext, QueryModel queryModel)
at Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor.OptimizeQueryModel(QueryModel queryModel, Boolean asyncQuery)
at Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor.CreateQueryExecutor[TResult](QueryModel queryModel)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.CompileQueryCore[TResult](Expression query, IQueryModelGenerator queryModelGenerator, IDatabase database, IDiagnosticsLogger`1 logger, Type contextType)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.<>c__DisplayClass13_0`1.<Execute>b__0()
at Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddQueryCore[TFunc](Object cacheKey, Func`1 compiler)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.Execute[TResult](Expression query)
at System.Linq.Queryable.Any[TSource](IQueryable`1 source)
at ModelNamespace.SomeRepository.TestMethod()
at TestNamespace.SomeRepositoryTest.TestMethod_Test()


After that I started the same build on the same commit again and it succeeded. Odd isn't it?



How the Tests are built up



To set up InMemoryDatabases, we use the following helper Class:



public class DbContextTestHelper
{
public static DbContextOptions<CustomContext> PrepareData(Action<CustomContext> createData)
{
var options = CreateDbContextOptions();
SaveData(options, createData);
return options;
}

private static void SaveData(DbContextOptions<CustomContext> options, Action<CustomContext> createData)
{
// Insert seed data into the database using one instance of the context
using (var context = new CustomContext(options))
{
createData.Invoke(context);
context.SaveChanges();
}
}

private static DbContextOptions<CustomContext> CreateDbContextOptions()
{
return new DbContextOptionsBuilder<CustomContext>()
.UseInMemoryDatabase(Guid.NewGuid()
.ToString()) //Database with same name gets reused, so let's isolate the tests from each other...
.Options;
}
}


So now we have many Tests we build up like this:



public class SomeRepositoryTest
{
[Fact]
public async Task TestMethod_Test()
{
var options = DbContextTestHelper.PrepareData(context =>
{
// do some initialisation
});
// Use a clean instance of the context to run the test
using (var context = new CustomContext(options))
{
var testee = new SomeRepository(context);
await testee.TestMethod(); // InvalidOperationException from above
// Assert something
}
}
}


Of course there are many cases where we create those DbContextOptions<CustomContext> and naturally they run parallel because of the built-in functionality that xUnit provides (yes of course not in the same class but for many test classes).



My Question



As far as I can tell there are few possibilities of why this can sometimes cause an exception:




  • the GUID's generated to ensure different instances of InMemoryDatabases are duplicates. However I'd rather not believe this.

  • there is a bug in the InMememory Database System

  • We are using InMemoryDatabases wrong


Do you know what's going on?



Edit 1:



As Requested, here's the TestMethod() where System.Linq.Queryable.Any[TSource](IQueryable'1 source) gets called.



    public void TestMethod(SomeObject someObject, List<DateTime> dates, bool someOption)
{
var res = _dbContext.SomeSet.Where(o =>
o.SomeObject.Equals(someObject) && dates.Contains(o.DateTime) && o.SomeOption == someOption);
if (res.Any()) // at System.Linq.Queryable.Any[TSource](IQueryable`1 source)
{
_dbContext.SomeSet.RemoveRange(res);
}
}









share|improve this question
























  • This appears to be an issue in EntityFrameworkCore github.com/IdentityServer/IdentityServer4/issues/2453. One suggested fix is to use ConcurrentDictionary
    – obl
    yesterday












  • @obl the point is, that im not at all accessing any dictionary. I only have an InMemoryDB and a DbContext. There are only DbSet<T> which I access. So im not really able to change this behavior.
    – LuckyLikey
    yesterday










  • Gotcha. Can you find the System.Linq.Queryable.Any[TSource](IQueryable`1 source) query mentioned in the stack trace and post it?
    – obl
    14 hours ago












  • @obl added it. hope it helps
    – LuckyLikey
    52 mins ago













up vote
2
down vote

favorite
1









up vote
2
down vote

favorite
1






1





I run Unit-Tests on TFS in a CI environment, today it failed with the following exception:



Error:
System.InvalidOperationException : Operations that change non-concurrent collections must have exclusive access. A concurrent update was performed on this collection and corrupted its state. The collection's state is no longer correct.
Stacktrace:
at System.Collections.Generic.Dictionary`2.FindEntry(TKey key)
at System.Collections.Generic.Dictionary`2.TryGetValue(TKey key, TValue& value)
at Microsoft.EntityFrameworkCore.Metadata.Internal.Model.GetDisplayName(Type type)
at Microsoft.EntityFrameworkCore.Metadata.Internal.Model.FindEntityType(Type type)
at Microsoft.EntityFrameworkCore.Query.ExpressionVisitors.Internal.EntityEqualityRewritingExpressionVisitor.RewriteEntityEquality(ExpressionType nodeType, Expression left, Expression right)
at Microsoft.EntityFrameworkCore.Query.ExpressionVisitors.Internal.EntityEqualityRewritingExpressionVisitor.VisitBinary(BinaryExpression binaryExpression)
at System.Linq.Expressions.BinaryExpression.Accept(ExpressionVisitor visitor)
at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)
at System.Linq.Expressions.ExpressionVisitor.VisitBinary(BinaryExpression node)
at Microsoft.EntityFrameworkCore.Query.ExpressionVisitors.Internal.EntityEqualityRewritingExpressionVisitor.VisitBinary(BinaryExpression binaryExpression)
at System.Linq.Expressions.BinaryExpression.Accept(ExpressionVisitor visitor)
at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)
at Remotion.Linq.Clauses.WhereClause.TransformExpressions(Func`2 transformation)
at Remotion.Linq.QueryModel.TransformExpressions(Func`2 transformation)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryOptimizer.Optimize(QueryCompilationContext queryCompilationContext, QueryModel queryModel)
at Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor.OptimizeQueryModel(QueryModel queryModel, Boolean asyncQuery)
at Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor.CreateQueryExecutor[TResult](QueryModel queryModel)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.CompileQueryCore[TResult](Expression query, IQueryModelGenerator queryModelGenerator, IDatabase database, IDiagnosticsLogger`1 logger, Type contextType)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.<>c__DisplayClass13_0`1.<Execute>b__0()
at Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddQueryCore[TFunc](Object cacheKey, Func`1 compiler)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.Execute[TResult](Expression query)
at System.Linq.Queryable.Any[TSource](IQueryable`1 source)
at ModelNamespace.SomeRepository.TestMethod()
at TestNamespace.SomeRepositoryTest.TestMethod_Test()


After that I started the same build on the same commit again and it succeeded. Odd isn't it?



How the Tests are built up



To set up InMemoryDatabases, we use the following helper Class:



public class DbContextTestHelper
{
public static DbContextOptions<CustomContext> PrepareData(Action<CustomContext> createData)
{
var options = CreateDbContextOptions();
SaveData(options, createData);
return options;
}

private static void SaveData(DbContextOptions<CustomContext> options, Action<CustomContext> createData)
{
// Insert seed data into the database using one instance of the context
using (var context = new CustomContext(options))
{
createData.Invoke(context);
context.SaveChanges();
}
}

private static DbContextOptions<CustomContext> CreateDbContextOptions()
{
return new DbContextOptionsBuilder<CustomContext>()
.UseInMemoryDatabase(Guid.NewGuid()
.ToString()) //Database with same name gets reused, so let's isolate the tests from each other...
.Options;
}
}


So now we have many Tests we build up like this:



public class SomeRepositoryTest
{
[Fact]
public async Task TestMethod_Test()
{
var options = DbContextTestHelper.PrepareData(context =>
{
// do some initialisation
});
// Use a clean instance of the context to run the test
using (var context = new CustomContext(options))
{
var testee = new SomeRepository(context);
await testee.TestMethod(); // InvalidOperationException from above
// Assert something
}
}
}


Of course there are many cases where we create those DbContextOptions<CustomContext> and naturally they run parallel because of the built-in functionality that xUnit provides (yes of course not in the same class but for many test classes).



My Question



As far as I can tell there are few possibilities of why this can sometimes cause an exception:




  • the GUID's generated to ensure different instances of InMemoryDatabases are duplicates. However I'd rather not believe this.

  • there is a bug in the InMememory Database System

  • We are using InMemoryDatabases wrong


Do you know what's going on?



Edit 1:



As Requested, here's the TestMethod() where System.Linq.Queryable.Any[TSource](IQueryable'1 source) gets called.



    public void TestMethod(SomeObject someObject, List<DateTime> dates, bool someOption)
{
var res = _dbContext.SomeSet.Where(o =>
o.SomeObject.Equals(someObject) && dates.Contains(o.DateTime) && o.SomeOption == someOption);
if (res.Any()) // at System.Linq.Queryable.Any[TSource](IQueryable`1 source)
{
_dbContext.SomeSet.RemoveRange(res);
}
}









share|improve this question















I run Unit-Tests on TFS in a CI environment, today it failed with the following exception:



Error:
System.InvalidOperationException : Operations that change non-concurrent collections must have exclusive access. A concurrent update was performed on this collection and corrupted its state. The collection's state is no longer correct.
Stacktrace:
at System.Collections.Generic.Dictionary`2.FindEntry(TKey key)
at System.Collections.Generic.Dictionary`2.TryGetValue(TKey key, TValue& value)
at Microsoft.EntityFrameworkCore.Metadata.Internal.Model.GetDisplayName(Type type)
at Microsoft.EntityFrameworkCore.Metadata.Internal.Model.FindEntityType(Type type)
at Microsoft.EntityFrameworkCore.Query.ExpressionVisitors.Internal.EntityEqualityRewritingExpressionVisitor.RewriteEntityEquality(ExpressionType nodeType, Expression left, Expression right)
at Microsoft.EntityFrameworkCore.Query.ExpressionVisitors.Internal.EntityEqualityRewritingExpressionVisitor.VisitBinary(BinaryExpression binaryExpression)
at System.Linq.Expressions.BinaryExpression.Accept(ExpressionVisitor visitor)
at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)
at System.Linq.Expressions.ExpressionVisitor.VisitBinary(BinaryExpression node)
at Microsoft.EntityFrameworkCore.Query.ExpressionVisitors.Internal.EntityEqualityRewritingExpressionVisitor.VisitBinary(BinaryExpression binaryExpression)
at System.Linq.Expressions.BinaryExpression.Accept(ExpressionVisitor visitor)
at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)
at Remotion.Linq.Clauses.WhereClause.TransformExpressions(Func`2 transformation)
at Remotion.Linq.QueryModel.TransformExpressions(Func`2 transformation)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryOptimizer.Optimize(QueryCompilationContext queryCompilationContext, QueryModel queryModel)
at Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor.OptimizeQueryModel(QueryModel queryModel, Boolean asyncQuery)
at Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor.CreateQueryExecutor[TResult](QueryModel queryModel)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.CompileQueryCore[TResult](Expression query, IQueryModelGenerator queryModelGenerator, IDatabase database, IDiagnosticsLogger`1 logger, Type contextType)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.<>c__DisplayClass13_0`1.<Execute>b__0()
at Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddQueryCore[TFunc](Object cacheKey, Func`1 compiler)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.Execute[TResult](Expression query)
at System.Linq.Queryable.Any[TSource](IQueryable`1 source)
at ModelNamespace.SomeRepository.TestMethod()
at TestNamespace.SomeRepositoryTest.TestMethod_Test()


After that I started the same build on the same commit again and it succeeded. Odd isn't it?



How the Tests are built up



To set up InMemoryDatabases, we use the following helper Class:



public class DbContextTestHelper
{
public static DbContextOptions<CustomContext> PrepareData(Action<CustomContext> createData)
{
var options = CreateDbContextOptions();
SaveData(options, createData);
return options;
}

private static void SaveData(DbContextOptions<CustomContext> options, Action<CustomContext> createData)
{
// Insert seed data into the database using one instance of the context
using (var context = new CustomContext(options))
{
createData.Invoke(context);
context.SaveChanges();
}
}

private static DbContextOptions<CustomContext> CreateDbContextOptions()
{
return new DbContextOptionsBuilder<CustomContext>()
.UseInMemoryDatabase(Guid.NewGuid()
.ToString()) //Database with same name gets reused, so let's isolate the tests from each other...
.Options;
}
}


So now we have many Tests we build up like this:



public class SomeRepositoryTest
{
[Fact]
public async Task TestMethod_Test()
{
var options = DbContextTestHelper.PrepareData(context =>
{
// do some initialisation
});
// Use a clean instance of the context to run the test
using (var context = new CustomContext(options))
{
var testee = new SomeRepository(context);
await testee.TestMethod(); // InvalidOperationException from above
// Assert something
}
}
}


Of course there are many cases where we create those DbContextOptions<CustomContext> and naturally they run parallel because of the built-in functionality that xUnit provides (yes of course not in the same class but for many test classes).



My Question



As far as I can tell there are few possibilities of why this can sometimes cause an exception:




  • the GUID's generated to ensure different instances of InMemoryDatabases are duplicates. However I'd rather not believe this.

  • there is a bug in the InMememory Database System

  • We are using InMemoryDatabases wrong


Do you know what's going on?



Edit 1:



As Requested, here's the TestMethod() where System.Linq.Queryable.Any[TSource](IQueryable'1 source) gets called.



    public void TestMethod(SomeObject someObject, List<DateTime> dates, bool someOption)
{
var res = _dbContext.SomeSet.Where(o =>
o.SomeObject.Equals(someObject) && dates.Contains(o.DateTime) && o.SomeOption == someOption);
if (res.Any()) // at System.Linq.Queryable.Any[TSource](IQueryable`1 source)
{
_dbContext.SomeSet.RemoveRange(res);
}
}






c# xunit in-memory-database ef-core-2.1 .net-core-2.1






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 56 mins ago

























asked yesterday









LuckyLikey

1,1821028




1,1821028












  • This appears to be an issue in EntityFrameworkCore github.com/IdentityServer/IdentityServer4/issues/2453. One suggested fix is to use ConcurrentDictionary
    – obl
    yesterday












  • @obl the point is, that im not at all accessing any dictionary. I only have an InMemoryDB and a DbContext. There are only DbSet<T> which I access. So im not really able to change this behavior.
    – LuckyLikey
    yesterday










  • Gotcha. Can you find the System.Linq.Queryable.Any[TSource](IQueryable`1 source) query mentioned in the stack trace and post it?
    – obl
    14 hours ago












  • @obl added it. hope it helps
    – LuckyLikey
    52 mins ago


















  • This appears to be an issue in EntityFrameworkCore github.com/IdentityServer/IdentityServer4/issues/2453. One suggested fix is to use ConcurrentDictionary
    – obl
    yesterday












  • @obl the point is, that im not at all accessing any dictionary. I only have an InMemoryDB and a DbContext. There are only DbSet<T> which I access. So im not really able to change this behavior.
    – LuckyLikey
    yesterday










  • Gotcha. Can you find the System.Linq.Queryable.Any[TSource](IQueryable`1 source) query mentioned in the stack trace and post it?
    – obl
    14 hours ago












  • @obl added it. hope it helps
    – LuckyLikey
    52 mins ago
















This appears to be an issue in EntityFrameworkCore github.com/IdentityServer/IdentityServer4/issues/2453. One suggested fix is to use ConcurrentDictionary
– obl
yesterday






This appears to be an issue in EntityFrameworkCore github.com/IdentityServer/IdentityServer4/issues/2453. One suggested fix is to use ConcurrentDictionary
– obl
yesterday














@obl the point is, that im not at all accessing any dictionary. I only have an InMemoryDB and a DbContext. There are only DbSet<T> which I access. So im not really able to change this behavior.
– LuckyLikey
yesterday




@obl the point is, that im not at all accessing any dictionary. I only have an InMemoryDB and a DbContext. There are only DbSet<T> which I access. So im not really able to change this behavior.
– LuckyLikey
yesterday












Gotcha. Can you find the System.Linq.Queryable.Any[TSource](IQueryable`1 source) query mentioned in the stack trace and post it?
– obl
14 hours ago






Gotcha. Can you find the System.Linq.Queryable.Any[TSource](IQueryable`1 source) query mentioned in the stack trace and post it?
– obl
14 hours ago














@obl added it. hope it helps
– LuckyLikey
52 mins ago




@obl added it. hope it helps
– LuckyLikey
52 mins ago

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53264875%2fxunit-inmemorydatabase-test-failure-invalidoperationexception%23new-answer', 'question_page');
}
);

Post as a guest





































active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53264875%2fxunit-inmemorydatabase-test-failure-invalidoperationexception%23new-answer', 'question_page');
}
);

Post as a guest




















































































Popular posts from this blog

How to change which sound is reproduced for terminal bell?

Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents

Can I use Tabulator js library in my java Spring + Thymeleaf project?