xUnit InMemoryDatabase Test failure: InvalidOperationException
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
add a comment |
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
This appears to be an issue inEntityFrameworkCore
github.com/IdentityServer/IdentityServer4/issues/2453. One suggested fix is to useConcurrentDictionary
– obl
Nov 12 '18 at 16:14
@obl the point is, that im not at all accessing any dictionary. I only have an InMemoryDB and a DbContext. There are onlyDbSet<T>
which I access. So im not really able to change this behavior.
– LuckyLikey
Nov 13 '18 at 6:03
Gotcha. Can you find theSystem.Linq.Queryable.Any[TSource](IQueryable`1 source)
query mentioned in the stack trace and post it?
– obl
Nov 13 '18 at 16:48
@obl added it. hope it helps
– LuckyLikey
Nov 14 '18 at 6:09
add a comment |
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
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
c# xunit in-memory-database ef-core-2.1 .net-core-2.1
edited Nov 14 '18 at 6:05
LuckyLikey
asked Nov 12 '18 at 15:02
LuckyLikeyLuckyLikey
1,2911131
1,2911131
This appears to be an issue inEntityFrameworkCore
github.com/IdentityServer/IdentityServer4/issues/2453. One suggested fix is to useConcurrentDictionary
– obl
Nov 12 '18 at 16:14
@obl the point is, that im not at all accessing any dictionary. I only have an InMemoryDB and a DbContext. There are onlyDbSet<T>
which I access. So im not really able to change this behavior.
– LuckyLikey
Nov 13 '18 at 6:03
Gotcha. Can you find theSystem.Linq.Queryable.Any[TSource](IQueryable`1 source)
query mentioned in the stack trace and post it?
– obl
Nov 13 '18 at 16:48
@obl added it. hope it helps
– LuckyLikey
Nov 14 '18 at 6:09
add a comment |
This appears to be an issue inEntityFrameworkCore
github.com/IdentityServer/IdentityServer4/issues/2453. One suggested fix is to useConcurrentDictionary
– obl
Nov 12 '18 at 16:14
@obl the point is, that im not at all accessing any dictionary. I only have an InMemoryDB and a DbContext. There are onlyDbSet<T>
which I access. So im not really able to change this behavior.
– LuckyLikey
Nov 13 '18 at 6:03
Gotcha. Can you find theSystem.Linq.Queryable.Any[TSource](IQueryable`1 source)
query mentioned in the stack trace and post it?
– obl
Nov 13 '18 at 16:48
@obl added it. hope it helps
– LuckyLikey
Nov 14 '18 at 6:09
This appears to be an issue in
EntityFrameworkCore
github.com/IdentityServer/IdentityServer4/issues/2453. One suggested fix is to use ConcurrentDictionary
– obl
Nov 12 '18 at 16:14
This appears to be an issue in
EntityFrameworkCore
github.com/IdentityServer/IdentityServer4/issues/2453. One suggested fix is to use ConcurrentDictionary
– obl
Nov 12 '18 at 16:14
@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
Nov 13 '18 at 6:03
@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
Nov 13 '18 at 6:03
Gotcha. Can you find the
System.Linq.Queryable.Any[TSource](IQueryable`1 source)
query mentioned in the stack trace and post it?– obl
Nov 13 '18 at 16:48
Gotcha. Can you find the
System.Linq.Queryable.Any[TSource](IQueryable`1 source)
query mentioned in the stack trace and post it?– obl
Nov 13 '18 at 16:48
@obl added it. hope it helps
– LuckyLikey
Nov 14 '18 at 6:09
@obl added it. hope it helps
– LuckyLikey
Nov 14 '18 at 6:09
add a comment |
0
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',
autoActivateHeartbeat: false,
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
This appears to be an issue in
EntityFrameworkCore
github.com/IdentityServer/IdentityServer4/issues/2453. One suggested fix is to useConcurrentDictionary
– obl
Nov 12 '18 at 16:14
@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
Nov 13 '18 at 6:03
Gotcha. Can you find the
System.Linq.Queryable.Any[TSource](IQueryable`1 source)
query mentioned in the stack trace and post it?– obl
Nov 13 '18 at 16:48
@obl added it. hope it helps
– LuckyLikey
Nov 14 '18 at 6:09