{"id":1104,"date":"2022-03-31T00:47:02","date_gmt":"2022-03-30T11:47:02","guid":{"rendered":"https:\/\/blog.wiseowls.co.nz\/?p=1104"},"modified":"2026-03-08T00:48:04","modified_gmt":"2026-03-07T11:48:04","slug":"ef-core-6-handling-json-data-in-sql-server","status":"publish","type":"post","link":"https:\/\/blog.wiseowls.co.nz\/index.php\/2022\/03\/31\/ef-core-6-handling-json-data-in-sql-server\/","title":{"rendered":"EF Core 6 \u2013 Handling JSON data in SQL Server"},"content":{"rendered":"<p>We have seen a few projects where the client insists on using SQL Server, but their workload generates a bunch of semi-structured JSON data for us to store. Now we need to bridge the gap and efficiently query it. One realistic case study where this situation may pop up would be building a browser extension that helps capture and organise wish lists from various platforms such as Amazon or eBay.<\/p>\n<h2 class=\"wp-block-heading\">Let&#8217;s build a wish list<\/h2>\n<p>Our journey would likely start with a web browser. We may have a browser extension of some sort that would send information about an item we&#8217;re currently watching to an API. That API will have to make sense of all different attributes each website provides and try store it in a way that makes querying as easy and efficient as possible.<\/p>\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"453\" src=\"https:\/\/blog.wiseowls.co.nz\/wp-content\/uploads\/2022\/03\/flowchart-step-4-1024x453.png\" alt=\"Flowchart showing wish list data flow from browser extension to API and SQL Server\" class=\"wp-image-1243\" srcset=\"https:\/\/blog.wiseowls.co.nz\/wp-content\/uploads\/2022\/03\/flowchart-step-4-1024x453.png 1024w, https:\/\/blog.wiseowls.co.nz\/wp-content\/uploads\/2022\/03\/flowchart-step-4-300x133.png 300w, https:\/\/blog.wiseowls.co.nz\/wp-content\/uploads\/2022\/03\/flowchart-step-4-768x340.png 768w, https:\/\/blog.wiseowls.co.nz\/wp-content\/uploads\/2022\/03\/flowchart-step-4-1200x531.png 1200w, https:\/\/blog.wiseowls.co.nz\/wp-content\/uploads\/2022\/03\/flowchart-step-4.png 1450w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/figure>\n<p>The catch is, we don&#8217;t know full list of attributes. And, probably, we should not care &#8211; perfect data model for frequently changing e-commerce websites would be hard to deduce and likely very painful to maintain. We could just lump it all together and chuck it into a schema-less data store like Cosmos DB or Mongo, but for the sake of argument we&#8217;ll imagine the client was adamant they needed a SQL Server because it&#8217;s a business decision they made a long time ago.<\/p>\n<h2 class=\"wp-block-heading\">Not a huge drama<\/h2>\n<p>SQL Server has functions to work with JSON data &#8211; all we have to do is put it into a sufficiently big column. We can save heaps of time creating one simple data model and calling it a day.<\/p>\n<p>Moving on to coding, let us focus on data retrieval and skip the API part for now &#8211; it&#8217;s a whole different can or worms and will distract us from our point. From here on we&#8217;ll be exploring ways to query the data<\/p>\n<h2 class=\"wp-block-heading\">Test Bench<\/h2>\n<p>We&#8217;ve created a small EF Core project where DBContext looks something like this:<\/p>\n<pre class=\"wp-block-code\"><code lang=\"csharp\" class=\"language-csharp\">class SHDbContext : DbContext\n{\n\tpublic DbSet&lt;WishlistEntry&gt; WishlistEntries { get; set; }\n\n\tprotected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)\n\t{\n\t\tbase.OnConfiguring(optionsBuilder);\n\t\toptionsBuilder.UseSqlServer(Environment.GetEnvironmentVariable(\"DB_CONNSTR\")).LogTo(Console.WriteLine);\n\t}\n}<\/code><\/pre>\n<p>where <code>WishlistEntry<\/code> is defined like so:<\/p>\n<pre class=\"wp-block-code\"><code lang=\"csharp\" class=\"language-csharp\">class WishlistEntry\n{\n\n\tpublic int Id { get; set; }\n\tpublic int CustomerId { get; set; }\n\t[MaxLength(300)]\n\tpublic string ItemSource { get; set; }\n\tpublic string ItemData { get; set; }\n\n\t[DatabaseGenerated(DatabaseGeneratedOption.Computed)]\n\tpublic string ItemCategory { get; set; }\n}\n\nclass ItemData\n{\n\tpublic string Sku { get; set; }\n\tpublic string Name { get; set; }\n\tpublic List&lt;Category&gt; Category { get; set; }\n}\n\nclass Category\n{\n\tpublic string Id { get; set; }\n\tpublic string Name { get; set; }\n}<\/code><\/pre>\n<p>with setup out of the way, let us define a sample entry and write a query to pick all entries that contain a category &#8220;Connected Home &amp; Housewares&#8221;:<\/p>\n<pre class=\"wp-block-code\"><code lang=\"json\" class=\"language-json\">{\n  \"sku\": 185267,\n  \"name\": \"Duracell - D Batteries (4-Pack)\",\n  \"type\": \"HardGood\",\n  \"price\": 9.99,\n  \"upc\": \"041333430010\",\n  \"category\": [\n    {\n      \"id\": \"pcmcat312300050015\",\n      \"name\": \"Connected Home &amp; Housewares\"\n    },\n    {\n      \"id\": \"pcmcat248700050021\",\n      \"name\": \"Housewares\"\n    },\n    {\n      \"id\": \"pcmcat303600050001\",\n      \"name\": \"Household Batteries\"\n    },\n    {\n      \"id\": \"abcat0208002\",\n      \"name\": \"Alkaline Batteries\"\n    }\n  ],\n  \"shipping\": 5.99,\n  \"description\": \"Compatible with select electronic devices; D size; DURALOCK Power Preserve technology; 4-pack\",\n  \"manufacturer\": \"Duracell\",\n  \"model\": \"MN1300R4Z\",\n  \"url\": \"http:\/\/www.bestbuy.com\/site\/duracell-d-batteries-4-pack\/185267.p?id=1051384046551&amp;skuId=185267&amp;cmp=RMXCC\",\n  \"image\": \"http:\/\/img.bbystatic.com\/BestBuy_US\/images\/products\/1852\/185267_sa.jpg\"\n}<\/code><\/pre>\n<h2 class=\"wp-block-heading\">Option one &#8211; JsonConvert.Deserialize<\/h2>\n<p>The naive approach to the desired outcome would be to simply try and deserialise the field and pray Entity Framework would work its magic:<\/p>\n<pre class=\"wp-block-code\"><code lang=\"csharp\" class=\"language-csharp\">var context = new SHDbContext();\n\/\/var sql = context.WishlistEntries.Select(wle =&gt; JsonConvert.DeserializeObject&lt;ItemData&gt;(wle.ItemData)\n\/\/                                                .Category.Any(c =&gt; c.Name == \"Connected Home &amp; Housewares\")); \/\/The LINQ expression 'c =&gt; c.Name == \"Connected Home &amp; Housewares\"' could not be translated. <\/code><\/pre>\n<p>Unfortunately, this would not even compile as EF has no idea what to do with <code>JsonConvert<\/code>. We&#8217;ll end up having to materialise the query and handle filtering on the client side:<\/p>\n<pre class=\"wp-block-code\"><code lang=\"csharp\" class=\"language-csharp\">var data = context.WishlistEntries.Select(wle =&gt; JsonConvert.DeserializeObject&lt;ItemData&gt;(wle.ItemData))\n                                .AsEnumerable()\n                                .Where(d =&gt; d.Category.Any(c =&gt; c.Name == \"Connected Home &amp; Housewares\"))\n                                .ToList();<\/code><\/pre>\n<p>This will work as expected, and some developers will probably stop here, but this is in fact a time bomb. When our wish lists get big enough, the clients will put a serious strain on SQL Server and the network fetching the whole table in its entirety. Not nice.<\/p>\n<h2 class=\"wp-block-heading\">Option two &#8211; write a Value Converter<\/h2>\n<p>Technically this is a variation of the previous option but leveraging <a href=\"https:\/\/docs.microsoft.com\/en-us\/ef\/core\/modeling\/value-conversions?tabs=data-annotations\">EF Core Value Conversion<\/a> capability for nicer looking query. To enable this, we&#8217;ll override <code>OnModelCreating<\/code> and add a few more lines to DB Context:<\/p>\n<pre class=\"wp-block-code\"><code lang=\"csharp\" class=\"language-csharp\">class SHDbContext : DbContext\n{\n\tpublic DbSet&lt;WishlistEntry&gt; WishlistEntries { get; set; }\n\n\tprotected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)\n\t{\n\t\tbase.OnConfiguring(optionsBuilder);\n\t\toptionsBuilder.UseSqlServer(Environment.GetEnvironmentVariable(\"DB_CONNSTR\")).LogTo(Console.WriteLine);\n\t}\n\n\tprotected override void OnModelCreating(ModelBuilder modelBuilder)\n\t{\n\t\tbase.OnModelCreating(modelBuilder);\n\t\tmodelBuilder.Entity&lt;WishlistEntry&gt;()\n\t\t            .Property(e =&gt; e.ItemData)\n\t\t            .HasConversion((itemData) =&gt; JsonConvert.SerializeObject(itemData), str =&gt; JsonConvert.DeserializeObject&lt;ItemData&gt;(str));\n\t}\n}\n\/\/ ...\n\/\/ finally, use the new converter like so:\nvar data = context.WishlistEntries.AsEnumerable().Where(d =&gt; d.ItemData.Category.Any(c =&gt; c.Name == \"Connected Home &amp; Housewares\")).ToList();\n \/\/ also not ideal as we still have to filter on client side, effectively scanning all tabl<\/code><\/pre>\n<p>This simply shifts the JSON conversion code up the food chain, so developers won&#8217;t see it often. Unfortunately, this &#8220;out of sight &#8211; out of mind&#8221; approach won&#8217;t improve our query plan.<\/p>\n<h2 class=\"wp-block-heading\">Option three &#8211; JSON_VALUE function<\/h2>\n<p>It gets pretty clear at this stage that we need to be able to filter by json fields on SQL Server side. Luckily, Microsoft provides a few <a href=\"https:\/\/docs.microsoft.com\/en-us\/sql\/t-sql\/functions\/json-functions-transact-sql?view=sql-server-ver15\">json-handling capabilities<\/a>. <a href=\"https:\/\/docs.microsoft.com\/en-us\/sql\/t-sql\/functions\/json-value-transact-sql?view=sql-server-ver15\">JSON_VALUE<\/a> function that allows extracting one value out of the blob via given path selector. This is going to eliminate the need to land our query and should hugely improve performance. Entity Framework does not support this function by default, but it should be <a href=\"https:\/\/blog.wiseowls.co.nz\/index.php\/2021\/10\/29\/ef-core-6-custom-functions-with-dbfunction-attribute\/\">very easy to add<\/a>:<\/p>\n<pre class=\"wp-block-code\"><code lang=\"csharp\" class=\"language-csharp\">\/\/ in the context class\n \/\/ adding static function to the DB Context\n[DbFunction(\"JSON_VALUE\", IsBuiltIn = true, IsNullable = false)]\npublic static string JsonValue(string expression, string path) =&gt; throw new NotImplementedException();<\/code><\/pre>\n<p>our query then becomes something like this:<\/p>\n<pre class=\"wp-block-code\"><code lang=\"csharp\" class=\"language-csharp\">var data = context.WishlistEntries.Where(d =&gt; SHDbContext.JsonValue(d.ItemData, \"$.category[0].name\").Contains(\"Connected Home &amp; Housewares\")).ToList();<\/code><\/pre>\n<p>And this is the correct answer. However, we can further improve performance by adding an index. Indexing the whole json blob will not help, but we can create a computed column with the value we care about and index that instead:<\/p>\n<pre class=\"wp-block-code\"><code lang=\"sql\" class=\"language-sql\">-- add computed column\nALTER TABLE WishlistEntries ADD ItemCategory AS JSON_VALUE(ItemData, '$.category[0].name')\n-- index the value\nCREATE INDEX IX_ItemCategory ON WishlistEntries(ItemCategory) INCLUDE(CustomerId, ItemSource, ItemData);\n-- finally, test if the query picks up index by running the following and checking the Actual Execution Plan:\n\/* test queries *\/\nSELECT * FROM [WishlistEntries] WHERE JSON_VALUE(ItemData, '$.category[0].name') = 'Connected Home &amp; Housewares'<\/code><\/pre>\n<p>This enhancement also happens to simplify our code a bit as we can now rely on computed column value when writing queries in EF:<\/p>\n<pre class=\"wp-block-code\"><code lang=\"csharp\" class=\"language-csharp\">\/\/ add computed column to WishlistEntry\nclass WishlistEntry\n{\n\n\tpublic int Id { get; set; }\n\tpublic int CustomerId { get; set; }\n\t[MaxLength(300)]\n\tpublic string ItemSource { get; set; }\n\tpublic string ItemData { get; set; } \n\n\t[DatabaseGenerated(DatabaseGeneratedOption.Computed)]\n\tpublic string ItemCategory { get; set; }\n}\n\n\/\/ finally the query will be like:\nvar data = context.WishlistEntries.Where(wle =&gt; wle.ItemCategory == \"Connected Home &amp; Housewares\").ToList();\n<\/code><\/pre>\n<h2 class=\"wp-block-heading\">Conclusion and area for improvement<\/h2>\n<p>Keen eyed readers may have noticed that we hardcoded query to first array item. This was a deliberate simplification we opted for to illustrate the point. It should be possible to query an array using OPENJSON &#8230; CROSS APPLY like so, but we haven&#8217;t explored this avenue far enough to see if we&#8217;d ultimately succeed:<\/p>\n<pre class=\"wp-block-code\"><code lang=\"csharp\" class=\"language-csharp\">var data = context.WishlistEntries.FromSqlRaw(@\"SELECT TOP 1 wishlist.*\n      FROM [WishlistEntries] as wishlist\nCROSS APPLY OPENJSON(ItemData, '$.category') WITH (CatName VARCHAR(200) '$.name') as categories\nWHERE categories.CatName = {0}\", \"Connected Home &amp; Housewares\").ToList();\n<\/code><\/pre>\n<p>Even though our application is far from complete we are in a good place. Equipped with these techniques, we can handle almost anything users throw at us and are still able to query data fast enough. The code for this exercise is <a href=\"https:\/\/github.com\/tkhadimullin\/FestiveTechCalendar2021-MishandlingJSON\">available on GitHub<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We have seen a few projects where the client insists on using SQL Server, but their workload generates a bunch of semi-structured JSON data for us to store. Now we need to bridge the gap and efficiently query it. One realistic case study where this situation may pop up would be building a browser extension &hellip; <a href=\"https:\/\/blog.wiseowls.co.nz\/index.php\/2022\/03\/31\/ef-core-6-handling-json-data-in-sql-server\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;EF Core 6 \u2013 Handling JSON data in SQL Server&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":360,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[11],"tags":[12,23,59],"class_list":["post-1104","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-dev","tag-c","tag-ef-core","tag-sql"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>EF Core 6 \u2013 Handling JSON data in SQL Server - Timur and associates<\/title>\n<meta name=\"description\" content=\"We&#039;ll explore options on how to query JSON data in SQL Server with Entity Framework Core 6. We&#039;ll also look at the performance of these solutions.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/blog.wiseowls.co.nz\/index.php\/2022\/03\/31\/ef-core-6-handling-json-data-in-sql-server\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"EF Core 6 \u2013 Handling JSON data in SQL Server - Timur and associates\" \/>\n<meta property=\"og:description\" content=\"We&#039;ll explore options on how to query JSON data in SQL Server with Entity Framework Core 6. We&#039;ll also look at the performance of these solutions.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/blog.wiseowls.co.nz\/index.php\/2022\/03\/31\/ef-core-6-handling-json-data-in-sql-server\/\" \/>\n<meta property=\"og:site_name\" content=\"Timur and associates\" \/>\n<meta property=\"article:published_time\" content=\"2022-03-30T11:47:02+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-03-07T11:48:04+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/blog.wiseowls.co.nz\/wp-content\/uploads\/2020\/02\/helloquence-5fNmWej4tAA-unsplash-scaled-e1581823690656.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"2560\" \/>\n\t<meta property=\"og:image:height\" content=\"1292\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"timur\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@TimurKh\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/blog.wiseowls.co.nz\\\/index.php\\\/2022\\\/03\\\/31\\\/ef-core-6-handling-json-data-in-sql-server\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/blog.wiseowls.co.nz\\\/index.php\\\/2022\\\/03\\\/31\\\/ef-core-6-handling-json-data-in-sql-server\\\/\"},\"author\":{\"name\":\"timur\",\"@id\":\"https:\\\/\\\/blog.wiseowls.co.nz\\\/#\\\/schema\\\/person\\\/34d0ed30d573b5bc317ea990bd2e0c59\"},\"headline\":\"EF Core 6 \u2013 Handling JSON data in SQL Server\",\"datePublished\":\"2022-03-30T11:47:02+00:00\",\"dateModified\":\"2026-03-07T11:48:04+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/blog.wiseowls.co.nz\\\/index.php\\\/2022\\\/03\\\/31\\\/ef-core-6-handling-json-data-in-sql-server\\\/\"},\"wordCount\":810,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/blog.wiseowls.co.nz\\\/index.php\\\/2022\\\/03\\\/31\\\/ef-core-6-handling-json-data-in-sql-server\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/blog.wiseowls.co.nz\\\/wp-content\\\/uploads\\\/2020\\\/02\\\/helloquence-5fNmWej4tAA-unsplash-scaled-e1581823690656.jpg\",\"keywords\":[\"c#\",\"ef-core\",\"sql\"],\"articleSection\":[\"Development\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/blog.wiseowls.co.nz\\\/index.php\\\/2022\\\/03\\\/31\\\/ef-core-6-handling-json-data-in-sql-server\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/blog.wiseowls.co.nz\\\/index.php\\\/2022\\\/03\\\/31\\\/ef-core-6-handling-json-data-in-sql-server\\\/\",\"url\":\"https:\\\/\\\/blog.wiseowls.co.nz\\\/index.php\\\/2022\\\/03\\\/31\\\/ef-core-6-handling-json-data-in-sql-server\\\/\",\"name\":\"EF Core 6 \u2013 Handling JSON data in SQL Server - Timur and associates\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/blog.wiseowls.co.nz\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/blog.wiseowls.co.nz\\\/index.php\\\/2022\\\/03\\\/31\\\/ef-core-6-handling-json-data-in-sql-server\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/blog.wiseowls.co.nz\\\/index.php\\\/2022\\\/03\\\/31\\\/ef-core-6-handling-json-data-in-sql-server\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/blog.wiseowls.co.nz\\\/wp-content\\\/uploads\\\/2020\\\/02\\\/helloquence-5fNmWej4tAA-unsplash-scaled-e1581823690656.jpg\",\"datePublished\":\"2022-03-30T11:47:02+00:00\",\"dateModified\":\"2026-03-07T11:48:04+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/blog.wiseowls.co.nz\\\/#\\\/schema\\\/person\\\/34d0ed30d573b5bc317ea990bd2e0c59\"},\"description\":\"We'll explore options on how to query JSON data in SQL Server with Entity Framework Core 6. We'll also look at the performance of these solutions.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/blog.wiseowls.co.nz\\\/index.php\\\/2022\\\/03\\\/31\\\/ef-core-6-handling-json-data-in-sql-server\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/blog.wiseowls.co.nz\\\/index.php\\\/2022\\\/03\\\/31\\\/ef-core-6-handling-json-data-in-sql-server\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/blog.wiseowls.co.nz\\\/index.php\\\/2022\\\/03\\\/31\\\/ef-core-6-handling-json-data-in-sql-server\\\/#primaryimage\",\"url\":\"https:\\\/\\\/blog.wiseowls.co.nz\\\/wp-content\\\/uploads\\\/2020\\\/02\\\/helloquence-5fNmWej4tAA-unsplash-scaled-e1581823690656.jpg\",\"contentUrl\":\"https:\\\/\\\/blog.wiseowls.co.nz\\\/wp-content\\\/uploads\\\/2020\\\/02\\\/helloquence-5fNmWej4tAA-unsplash-scaled-e1581823690656.jpg\",\"width\":2560,\"height\":1292},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/blog.wiseowls.co.nz\\\/index.php\\\/2022\\\/03\\\/31\\\/ef-core-6-handling-json-data-in-sql-server\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/blog.wiseowls.co.nz\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"EF Core 6 \u2013 Handling JSON data in SQL Server\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/blog.wiseowls.co.nz\\\/#website\",\"url\":\"https:\\\/\\\/blog.wiseowls.co.nz\\\/\",\"name\":\"Timur and associates\",\"description\":\"Notes of an IT contractor\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/blog.wiseowls.co.nz\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/blog.wiseowls.co.nz\\\/#\\\/schema\\\/person\\\/34d0ed30d573b5bc317ea990bd2e0c59\",\"name\":\"timur\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/23d55e17d4f0990ee4d12bc6e5dcfb58a292934efd62a185756876379e780b16?s=96&r=pg\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/23d55e17d4f0990ee4d12bc6e5dcfb58a292934efd62a185756876379e780b16?s=96&r=pg\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/23d55e17d4f0990ee4d12bc6e5dcfb58a292934efd62a185756876379e780b16?s=96&r=pg\",\"caption\":\"timur\"},\"sameAs\":[\"https:\\\/\\\/x.com\\\/TimurKh\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"EF Core 6 \u2013 Handling JSON data in SQL Server - Timur and associates","description":"We'll explore options on how to query JSON data in SQL Server with Entity Framework Core 6. We'll also look at the performance of these solutions.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/blog.wiseowls.co.nz\/index.php\/2022\/03\/31\/ef-core-6-handling-json-data-in-sql-server\/","og_locale":"en_US","og_type":"article","og_title":"EF Core 6 \u2013 Handling JSON data in SQL Server - Timur and associates","og_description":"We'll explore options on how to query JSON data in SQL Server with Entity Framework Core 6. We'll also look at the performance of these solutions.","og_url":"https:\/\/blog.wiseowls.co.nz\/index.php\/2022\/03\/31\/ef-core-6-handling-json-data-in-sql-server\/","og_site_name":"Timur and associates","article_published_time":"2022-03-30T11:47:02+00:00","article_modified_time":"2026-03-07T11:48:04+00:00","og_image":[{"width":2560,"height":1292,"url":"https:\/\/blog.wiseowls.co.nz\/wp-content\/uploads\/2020\/02\/helloquence-5fNmWej4tAA-unsplash-scaled-e1581823690656.jpg","type":"image\/jpeg"}],"author":"timur","twitter_card":"summary_large_image","twitter_creator":"@TimurKh","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/blog.wiseowls.co.nz\/index.php\/2022\/03\/31\/ef-core-6-handling-json-data-in-sql-server\/#article","isPartOf":{"@id":"https:\/\/blog.wiseowls.co.nz\/index.php\/2022\/03\/31\/ef-core-6-handling-json-data-in-sql-server\/"},"author":{"name":"timur","@id":"https:\/\/blog.wiseowls.co.nz\/#\/schema\/person\/34d0ed30d573b5bc317ea990bd2e0c59"},"headline":"EF Core 6 \u2013 Handling JSON data in SQL Server","datePublished":"2022-03-30T11:47:02+00:00","dateModified":"2026-03-07T11:48:04+00:00","mainEntityOfPage":{"@id":"https:\/\/blog.wiseowls.co.nz\/index.php\/2022\/03\/31\/ef-core-6-handling-json-data-in-sql-server\/"},"wordCount":810,"commentCount":0,"image":{"@id":"https:\/\/blog.wiseowls.co.nz\/index.php\/2022\/03\/31\/ef-core-6-handling-json-data-in-sql-server\/#primaryimage"},"thumbnailUrl":"https:\/\/blog.wiseowls.co.nz\/wp-content\/uploads\/2020\/02\/helloquence-5fNmWej4tAA-unsplash-scaled-e1581823690656.jpg","keywords":["c#","ef-core","sql"],"articleSection":["Development"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/blog.wiseowls.co.nz\/index.php\/2022\/03\/31\/ef-core-6-handling-json-data-in-sql-server\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/blog.wiseowls.co.nz\/index.php\/2022\/03\/31\/ef-core-6-handling-json-data-in-sql-server\/","url":"https:\/\/blog.wiseowls.co.nz\/index.php\/2022\/03\/31\/ef-core-6-handling-json-data-in-sql-server\/","name":"EF Core 6 \u2013 Handling JSON data in SQL Server - Timur and associates","isPartOf":{"@id":"https:\/\/blog.wiseowls.co.nz\/#website"},"primaryImageOfPage":{"@id":"https:\/\/blog.wiseowls.co.nz\/index.php\/2022\/03\/31\/ef-core-6-handling-json-data-in-sql-server\/#primaryimage"},"image":{"@id":"https:\/\/blog.wiseowls.co.nz\/index.php\/2022\/03\/31\/ef-core-6-handling-json-data-in-sql-server\/#primaryimage"},"thumbnailUrl":"https:\/\/blog.wiseowls.co.nz\/wp-content\/uploads\/2020\/02\/helloquence-5fNmWej4tAA-unsplash-scaled-e1581823690656.jpg","datePublished":"2022-03-30T11:47:02+00:00","dateModified":"2026-03-07T11:48:04+00:00","author":{"@id":"https:\/\/blog.wiseowls.co.nz\/#\/schema\/person\/34d0ed30d573b5bc317ea990bd2e0c59"},"description":"We'll explore options on how to query JSON data in SQL Server with Entity Framework Core 6. We'll also look at the performance of these solutions.","breadcrumb":{"@id":"https:\/\/blog.wiseowls.co.nz\/index.php\/2022\/03\/31\/ef-core-6-handling-json-data-in-sql-server\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/blog.wiseowls.co.nz\/index.php\/2022\/03\/31\/ef-core-6-handling-json-data-in-sql-server\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/blog.wiseowls.co.nz\/index.php\/2022\/03\/31\/ef-core-6-handling-json-data-in-sql-server\/#primaryimage","url":"https:\/\/blog.wiseowls.co.nz\/wp-content\/uploads\/2020\/02\/helloquence-5fNmWej4tAA-unsplash-scaled-e1581823690656.jpg","contentUrl":"https:\/\/blog.wiseowls.co.nz\/wp-content\/uploads\/2020\/02\/helloquence-5fNmWej4tAA-unsplash-scaled-e1581823690656.jpg","width":2560,"height":1292},{"@type":"BreadcrumbList","@id":"https:\/\/blog.wiseowls.co.nz\/index.php\/2022\/03\/31\/ef-core-6-handling-json-data-in-sql-server\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/blog.wiseowls.co.nz\/"},{"@type":"ListItem","position":2,"name":"EF Core 6 \u2013 Handling JSON data in SQL Server"}]},{"@type":"WebSite","@id":"https:\/\/blog.wiseowls.co.nz\/#website","url":"https:\/\/blog.wiseowls.co.nz\/","name":"Timur and associates","description":"Notes of an IT contractor","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/blog.wiseowls.co.nz\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/blog.wiseowls.co.nz\/#\/schema\/person\/34d0ed30d573b5bc317ea990bd2e0c59","name":"timur","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/23d55e17d4f0990ee4d12bc6e5dcfb58a292934efd62a185756876379e780b16?s=96&r=pg","url":"https:\/\/secure.gravatar.com\/avatar\/23d55e17d4f0990ee4d12bc6e5dcfb58a292934efd62a185756876379e780b16?s=96&r=pg","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/23d55e17d4f0990ee4d12bc6e5dcfb58a292934efd62a185756876379e780b16?s=96&r=pg","caption":"timur"},"sameAs":["https:\/\/x.com\/TimurKh"]}]}},"_links":{"self":[{"href":"https:\/\/blog.wiseowls.co.nz\/index.php\/wp-json\/wp\/v2\/posts\/1104","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.wiseowls.co.nz\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.wiseowls.co.nz\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.wiseowls.co.nz\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.wiseowls.co.nz\/index.php\/wp-json\/wp\/v2\/comments?post=1104"}],"version-history":[{"count":13,"href":"https:\/\/blog.wiseowls.co.nz\/index.php\/wp-json\/wp\/v2\/posts\/1104\/revisions"}],"predecessor-version":[{"id":1348,"href":"https:\/\/blog.wiseowls.co.nz\/index.php\/wp-json\/wp\/v2\/posts\/1104\/revisions\/1348"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.wiseowls.co.nz\/index.php\/wp-json\/wp\/v2\/media\/360"}],"wp:attachment":[{"href":"https:\/\/blog.wiseowls.co.nz\/index.php\/wp-json\/wp\/v2\/media?parent=1104"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.wiseowls.co.nz\/index.php\/wp-json\/wp\/v2\/categories?post=1104"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.wiseowls.co.nz\/index.php\/wp-json\/wp\/v2\/tags?post=1104"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}