简体   繁体   English

postgressql jsonb 的 entityframework 核心中的等效数据类型

[英]Equivalent datatype in entityframework core for postgressql's jsonb

I am using EntityFrameworkCore and PostgresSql in my application.我在我的应用程序中使用 EntityFrameworkCore 和 PostgresSql。 Further I am using code first approach to generate the db tables.此外,我使用代码优先方法来生成数据库表。 Now there is a column for which I want datatype as jsonb in postgres but I do not see such datatype in EntityFrameworkCore.现在有一个列,我希望 postgres 中的数据类型为 jsonb,但我在 EntityFrameworkCore 中看不到这样的数据类型。 In C# I tried with adding an attribute as [Column(TypeName="jsonb")] but still datatpe in postgres is text and I am able to insert non-jsonb data in my column using insert script which I don't want.在 C# 中,我尝试将属性添加为 [Column(TypeName="jsonb")] 但 postgres 中的 datatpe 仍然是文本,我可以使用我不想要的插入脚本在我的列中插入非 jsonb 数据。 So just want to check is there a way to fix this?所以只想检查有没有办法解决这个问题?

在此处输入图像描述

在此处输入图像描述

Instead of a string , try using the JsonDocument type.尝试使用JsonDocument类型,而不是string

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM