我目前正在使用 postgres 枚举
CREATE TYPE http_action_enum AS ENUM ('GET', 'HEAD', 'POST', 'PUT', 'DELETE', 'CONNECT', 'OPTIONS', 'TRACE', 'PATCH');
CREATE TABLE IF NOT EXISTS response
(
id UUID PRIMARY KEY,
http_action http_action_enum NOT NULL
);
Run Code Online (Sandbox Code Playgroud)
但是当我使用 ef 框架插入 postgres 数据库时,我不断遇到以下错误:
Exception data:
Severity: ERROR
SqlState: 42804
MessageText: column "destination" is of type source_dest_enum but expression is of type integer
Hint: You will need to rewrite or cast the expression.
Run Code Online (Sandbox Code Playgroud)
当我检查响应数据类型时,它实际上是正确的枚举而不是整数。
存储库.cs
public async Task<Response> InsertRecord(Response response, CancellationToken cancellationToken)
{
await dBContext.response.AddAsync(response, cancellationToken).ConfigureAwait(true); …Run Code Online (Sandbox Code Playgroud)