Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to set comment on JSON column #33375

Open
tai-yi opened this issue Mar 22, 2024 · 2 comments
Open

How to set comment on JSON column #33375

tai-yi opened this issue Mar 22, 2024 · 2 comments

Comments

@tai-yi
Copy link

tai-yi commented Mar 22, 2024

Ask a question

How to set comment on JSON column

Include your code

I tried use CommentAttribute , but doesn't work.

public class JsonTable{
   ...
  [Comment("xxx")]
  public SampleJsonDataType  Data {get;set;}
}

[Comment("xxx")]
public class SampleJsonDataType  {
     ...
     ...
}

class JsonTableEntityConfiguration: IEntityTypeConfiguration<JsonTable>
{
   public void Configure(EntityTypeBuilder<JsonTable> builder){
    builder.OwnsOne(p => p.Data, ownedNavigationBuilder =>
    {
          ownedNavigationBuilder.ToJson();
       }
   }
}

Include provider and version information

EF Core version: 8
Database provider: Microsoft.EntityFrameworkCore.SqlServer

@maumar
Copy link
Contributor

maumar commented Apr 11, 2024

Currently JSON entities are internally mapped using owned types, which don't allow setting comment on them. Once we enable mapping JSON using complex types, this should light up "for free". #31252

On top of that we could consider adding this for owned types also, We have SetContainerColumnName, could add SetContainerColumnComment or something similar, and expose it via ToJson @AndriySvyryd thoughts?

@maumar maumar added this to the 9.0.0 milestone Apr 11, 2024
@AndriySvyryd
Copy link
Member

We already allow setting table comments for owned types, we can reuse the same metadata for JSON column comment.

@maumar maumar modified the milestones: 9.0.0, Backlog Aug 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants