diff --git a/src/EFCore.Design/Design/Internal/CSharpHelper.cs b/src/EFCore.Design/Design/Internal/CSharpHelper.cs
index 5ce188f3c48..ebdd0a8bc4b 100644
--- a/src/EFCore.Design/Design/Internal/CSharpHelper.cs
+++ b/src/EFCore.Design/Design/Internal/CSharpHelper.cs
@@ -8,6 +8,7 @@
using System.Globalization;
using System.Linq;
using System.Linq.Expressions;
+using System.Numerics;
using System.Text;
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore.Internal;
@@ -161,7 +162,8 @@ public CSharpHelper([NotNull] IRelationalTypeMappingSource relationalTypeMapping
{ typeof(TimeSpan), (c, v) => c.Literal((TimeSpan)v) },
{ typeof(uint), (c, v) => c.Literal((uint)v) },
{ typeof(ulong), (c, v) => c.Literal((ulong)v) },
- { typeof(ushort), (c, v) => c.Literal((ushort)v) }
+ { typeof(ushort), (c, v) => c.Literal((ushort)v) },
+ { typeof(BigInteger), (c, v) => c.Literal((BigInteger)v) }
};
///
@@ -497,6 +499,12 @@ public virtual string Literal(TimeSpan value)
///
public virtual string Literal(ushort value) => "(ushort)" + value;
+ ///
+ /// This API supports the Entity Framework Core infrastructure and is not intended to be used
+ /// directly from your code. This API may change or be removed in future releases.
+ ///
+ public virtual string Literal(BigInteger value) => $"BigInteger.Parse(\"{value.ToString(NumberFormatInfo.InvariantInfo)}\", NumberFormatInfo.InvariantInfo)";
+
///
/// This API supports the Entity Framework Core infrastructure and is not intended to be used
/// directly from your code. This API may change or be removed in future releases.
diff --git a/test/EFCore.Design.Tests/Design/Internal/CSharpHelperTest.cs b/test/EFCore.Design.Tests/Design/Internal/CSharpHelperTest.cs
index f9d8a9fd4e7..94a2841e7f5 100644
--- a/test/EFCore.Design.Tests/Design/Internal/CSharpHelperTest.cs
+++ b/test/EFCore.Design.Tests/Design/Internal/CSharpHelperTest.cs
@@ -4,6 +4,7 @@
using System;
using System.Data.SqlTypes;
using System.Linq.Expressions;
+using System.Numerics;
using Microsoft.EntityFrameworkCore.Internal;
using Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal;
using Microsoft.EntityFrameworkCore.Storage;
@@ -213,6 +214,12 @@ public void Literal_works_when_MultidimensionalArray()
result);
}
+ [Fact]
+ public void Literal_works_when_BigInteger() =>
+ Literal_works(
+ new BigInteger(42),
+ "BigInteger.Parse(\"42\", NumberFormatInfo.InvariantInfo)");
+
[Fact]
public void UnknownLiteral_throws_when_unknown()
{