微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

用于查询 CockroachDB 的实体框架 ArgumentOutOfRangeException?

如何解决用于查询 CockroachDB 的实体框架 ArgumentOutOfRangeException?

我有一个 kubernetes 集群,运行一些现有的 ASP.NET 应用程序,这些应用程序曾经在 Postgresql 数据库前使用实体框架。我使用 Npgsql.EntityFrameworkCore.Postgresql 客户端驱动程序。我正在尝试用 CockroachDB 替换数据库,我已经做到了:

  • 我可以创建和部署 cockroachdb
  • 我可以从应用程序连接到 cockroachdb
  • 正确创建了数据库

我有一个简单的插入,我已经确认它在 postgres 上有效,但在 cockroachdb 上不起作用。我已启用敏感数据记录功能,但我可以获得更多信息吗?

我发现了这个未解决的问题:https://github.com/cockroachdb/cockroach/issues/48050

我已尝试使用 options.UseNpgsql(connectionString,o => o.SetPostgresversion(9,6))optionsBuilder.UseSerialColumns(); 解决此问题,以避免与 Postgres 10.x 的兼容性问题 - 两者似乎都无法解决我的问题。

SQL查询错误

Executed DbCommand (5ms) [Parameters=[@p0='1d808b9a-6cb3-48b6-b5a3-961f98e941b9' (Nullable = false),@p1='2021-02-06T22:28:01.3495134+00:00' (DbType = DateTime),@p2='my@email.com' (Nullable = false),@p3='2021-02-06T22:28:01.3495134+00:00' (DbType = DateTime)],CommandType='Text',CommandTimeout='30']
      INSERT INTO "Accounts" ("MyIdentityName","Created","Email","LastChanged")
      VALUES (@p0,@p1,@p2,@p3)
      RETURNING "Id";
      An exception occurred in the database while saving changes for context type 'KlusterManager.Data.DataMainDbContext'.
      Microsoft.EntityFrameworkCore.dbupdateException: An error occurred while updating the entries. See the inner exception for details.
       ---> System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')
         at System.Collections.Generic.List`1.get_Item(Int32 index)
         at Npgsql.EntityFrameworkCore.Postgresql.Update.Internal.NpgsqlModificationCommandBatch.ConsumeAsync(RelationalDataReader reader,CancellationToken cancellationToken)
         at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.ExecuteAsync(IRelationalConnection connection,CancellationToken cancellationToken)
         --- End of inner exception stack trace ---
         at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.ExecuteAsync(IRelationalConnection connection,CancellationToken cancellationToken)
         at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable`1 commandBatches,IRelationalConnection connection,CancellationToken cancellationToken)
         at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(IList`1 entriesToSave,CancellationToken cancellationToken)
         at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(DbContext _,Boolean acceptAllChangesOnSuccess,CancellationToken cancellationToken)
         at Npgsql.EntityFrameworkCore.Postgresql.Storage.Internal.NpgsqlExecutionStrategy.ExecuteAsync[TState,TResult](TState state,Func`4 operation,Func`4 verifySucceeded,CancellationToken cancellationToken)
         at Microsoft.EntityFrameworkCore.DbContext.SaveChangesAsync(Boolean acceptAllChangesOnSuccess,CancellationToken cancellationToken)
      Microsoft.EntityFrameworkCore.dbupdateException: An error occurred while updating the entries. See the inner exception for details.
       ---> System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')
         at System.Collections.Generic.List`1.get_Item(Int32 index)
         at Npgsql.EntityFrameworkCore.Postgresql.Update.Internal.NpgsqlModificationCommandBatch.ConsumeAsync(RelationalDataReader reader,CancellationToken cancellationToken)

我也将 Account 模型用作 gRPC DTO,这意味着它具有 protobuf 注释。这些中的任何一个会干扰实体框架吗?同样,该查询适用于 Postgres,但不适用于 CockroachDB

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?