{"id":20322375,"url":"https://github.com/iozcelik/entityframeworkcore.sqlserver.jsonextention","last_synced_at":"2025-10-05T07:56:28.354Z","repository":{"id":115707252,"uuid":"278012212","full_name":"iozcelik/EntityFrameworkCore.SqlServer.JsonExtention","owner":"iozcelik","description":"Support MsSql 2016 Json column function to working with Entity Framework Core 6","archived":false,"fork":false,"pushed_at":"2022-03-09T14:54:41.000Z","size":48,"stargazers_count":8,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-10-05T07:56:26.924Z","etag":null,"topics":["ef-core","json","mssql"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/iozcelik.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-07-08T06:48:52.000Z","updated_at":"2025-09-25T16:27:09.000Z","dependencies_parsed_at":null,"dependency_job_id":"9fbf9874-65cd-49f4-87e2-570006e8ef17","html_url":"https://github.com/iozcelik/EntityFrameworkCore.SqlServer.JsonExtention","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/iozcelik/EntityFrameworkCore.SqlServer.JsonExtention","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iozcelik%2FEntityFrameworkCore.SqlServer.JsonExtention","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iozcelik%2FEntityFrameworkCore.SqlServer.JsonExtention/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iozcelik%2FEntityFrameworkCore.SqlServer.JsonExtention/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iozcelik%2FEntityFrameworkCore.SqlServer.JsonExtention/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iozcelik","download_url":"https://codeload.github.com/iozcelik/EntityFrameworkCore.SqlServer.JsonExtention/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iozcelik%2FEntityFrameworkCore.SqlServer.JsonExtention/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278425493,"owners_count":25984687,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-05T02:00:06.059Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ef-core","json","mssql"],"created_at":"2024-11-14T19:21:29.917Z","updated_at":"2025-10-05T07:56:28.313Z","avatar_url":"https://github.com/iozcelik.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"MsSql Json Extention for Entity Framework Core 6\n======================\n\nThis extention aim is define json columns and querying them.\n\n### Get it for .Net 6\n```\nPM\u003e Install-Package EntityFrameworkCore.SqlServer.JsonExtention -Version 2.0.0\n```\n\n### Get it for .Net 3.1\n```\nPM\u003e Install-Package EntityFrameworkCore.SqlServer.JsonExtention -Version 1.0.0\n```\n\n### Basic usage\n#### Add Option Builder First\nInside dbcontext OnConfiguring method, call UseJsonExtention()\n\n```csharp\nprotected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) {\n    base.OnConfiguring(optionsBuilder);\n    optionsBuilder.UseJsonFunctions();\n}\n```\n\n#### Add Json Conversion \nUsing Fluent api in model builder and just call HasJsonConversion() method.\n\n```csharp\nmodelBuilder.Entity\u003cCountry\u003e().Property(p =\u003e p.CountryDetail).HasJsonConversion();\n```\n\n#### Supported Conversion \nThe library supports List\u003c\u003e, Dictionary\u003cstring,object\u003e and custom entity types.\n\nExample entities:\n```csharp\npublic class Country\n{\n    public int Id { get; set; }\n    public string Name { get; set; }\n    public CountryDetail CountryDetail { get; set; }\n    public Dictionary\u003cstring, object\u003e ExtraInformation { get; set; }\n    public List\u003cstring\u003e OfficialLanguages { get; set; }\n    public List\u003cint\u003e UtcTimeZones { get; set; }\n}\n\npublic class CountryDetail\n{\n    public string Code { get; set; }\n    public DateTime? Founded { get; set; }\n    public List\u003cCity\u003e Cities { get; set; }\n}\n\npublic class City\n{\n    public string Name { get; set; }\n    public DateTime? Founded { get; set; }\n    public int? Population { get; set; }\n}\n```\n\nAnd usage in dbcontext:\n```csharp\npublic class TestContext : DbContext {\n    public DbSet\u003cCountry\u003e Countries { get; set; }\n\n    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) {\n        base.OnConfiguring(optionsBuilder);\n        optionsBuilder.UseSqlServer(\"Data Source=.;Initial Catalog=JsonExtentionTest;Integrated Security=True\",\n            providerOptions =\u003e providerOptions.CommandTimeout(60));\n\n        optionsBuilder.UseJsonFunctions();\n    }\n\n    protected override void OnModelCreating(ModelBuilder modelBuilder) {\n        modelBuilder.Entity\u003cCountry\u003e().Property(p =\u003e p.CountryDetail).HasJsonConversion();\n        modelBuilder.Entity\u003cCountry\u003e().Property(p =\u003e p.ExtraInformation).HasJsonConversion();\n        modelBuilder.Entity\u003cCountry\u003e().Property(p =\u003e p.UtcTimeZones).HasJsonConversion();\n        modelBuilder.Entity\u003cCountry\u003e().Property(p =\u003e p.OfficialLanguages).HasJsonConversion();\n    }\n}\n```\n\n### Querying\nSupported Json functions are:\n```sql\nISJSON    : Tests whether a string contains valid JSON.\nJSON_VALUE: Extracts a scalar value from a JSON string.\nJSON_QUERY: Extracts an object or an array from a JSON string.\n```\n[Mssql documentation](https://docs.microsoft.com/en-us/sql/t-sql/functions/json-functions-transact-sql?view=sql-server-ver15)\n\n#### ISJSON\n```csharp\nvar isJsons = _context.Countries.Select(s =\u003e EF.Functions.IsJson(s.CountryDetail)).ToList();\n```\n\nGenerated SQL query\n```sql\nSELECT ISJSON([c].[CountryDetail])\nFROM [Countries] AS [c]\n```\n\n#### JSON_VALUE\n```csharp\nvar phones = _context.Countries\n                .Where(w =\u003e EF.Functions.JsonValue(w.ExtraInformation, \"InternetTLD\") != null)\n                .OrderByDescending(o =\u003e EF.Functions.JsonValue(o.ExtraInformation, \"InternetTLD\"))\n                .Select(s =\u003e EF.Functions.JsonValue(s.ExtraInformation, \"InternetTLD\"))\n                .ToList();\n```\n\nGenerated SQL query\n```sql\nSELECT JSON_VALUE([c].[ExtraInformation], '$.InternetTLD')\nFROM [Countries] AS [c]\nWHERE JSON_VALUE([c].[ExtraInformation], '$.InternetTLD') IS NOT NULL\nORDER BY JSON_VALUE([c].[ExtraInformation], '$.InternetTLD') DESC\n```\n\n#### JSON_QUERY\n```csharp\nvar entityId = 1;\n\nvar result = _context.Countries.Where(w =\u003e w.Id == entityId).Select(s =\u003e EF.Functions.JsonQuery(s.CountryDetail, \"Cities\")).FirstOrDefault();\n\nvar cities = JsonSerializer.Deserialize\u003cList\u003cCity\u003e\u003e(result);\n```\n\nGenerated SQL query\n```sql\nSELECT TOP(1) JSON_QUERY([c].[CountryDetail], '$.Cities')\nFROM [Countries] AS [c]\nWHERE [c].[Id] = 1\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiozcelik%2Fentityframeworkcore.sqlserver.jsonextention","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiozcelik%2Fentityframeworkcore.sqlserver.jsonextention","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiozcelik%2Fentityframeworkcore.sqlserver.jsonextention/lists"}