<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Coder Legion - Recent posts tagged entityframework</title>
<link>https://coderlegion.com/tag/entityframework</link>
<description>Powered by Question2Answer</description>
<item>
<title>SQL Server and Azure SQL Updates with EF Core 10</title>
<link>https://coderlegion.com/9100/sql-server-and-azure-sql-updates-with-ef-core-10</link>
<description>&lt;p&gt;EF Core 10 was released in November 2025 together with .NET 10 and is an LTS release supported until 2028. This version mainly focuses on better alignment with new SQL Server capabilities rather than introducing radically new concepts.&lt;/p&gt;
&lt;p&gt;Below are a few changes that are worth noting from a practical point of view.&lt;/p&gt;
&lt;h3 id=&quot;vector-data-type-support&quot;&gt;Vector data type support&lt;/h3&gt;
&lt;p&gt;EF Core 10 adds direct support for the &lt;strong&gt;vector&lt;/strong&gt; data type introduced in SQL Server 2025 and Azure SQL. This makes it possible to store embeddings directly in the database without additional workarounds.&lt;/p&gt;
&lt;p&gt;A simple entity example looks like this:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-csharp&quot;&gt;public class Blog
{
    public int Id { get; set; }

    [Column(TypeName = &quot;vector(1536)&quot;)]
    public SqlVector&amp;lt;float&amp;gt; Embedding { get; set; }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Once the embedding is generated on the application side, it can be saved using the standard EF workflow:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-csharp&quot;&gt;context.Blogs.Add(new Blog
{
    Embedding = new SqlVector&amp;lt;float&amp;gt;(embedding)
});

await context.SaveChangesAsync();
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Similarity queries can also be written directly in LINQ using &lt;code&gt;EF.Functions.VectorDistance&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-csharp&quot;&gt;var blogs = await context.Blogs
    .OrderBy(b =&amp;gt; EF.Functions.VectorDistance(&quot;cosine&quot;, b.Embedding, queryVector))
    .Take(3)
    .ToListAsync();
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This is useful in scenarios such as semantic search or basic recommendation logic, without needing custom SQL or external query layers.&lt;/p&gt;
&lt;h3 id=&quot;native-json-data-type-mapping&quot;&gt;Native JSON data type mapping&lt;/h3&gt;
&lt;p&gt;With SQL Server 2025, JSON can now be stored using a dedicated &lt;strong&gt;json&lt;/strong&gt; data type. EF Core 10 supports this natively and uses it automatically when the compatibility level allows it.&lt;/p&gt;
&lt;p&gt;For example:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-csharp&quot;&gt;public class Blog
{
    public int Id { get; set; }
    public string[] Tags { get; set; }
    public BlogDetails Details { get; set; }
}

public class BlogDetails
{
    public int Viewers { get; set; }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Model configuration:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-csharp&quot;&gt;modelBuilder.Entity&amp;lt;Blog&amp;gt;()
    .ComplexProperty(b =&amp;gt; b.Details, b =&amp;gt; b.ToJson());
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;With this setup, both &lt;code&gt;Tags&lt;/code&gt; and &lt;code&gt;Details&lt;/code&gt; are created as &lt;code&gt;json&lt;/code&gt; columns in the database.&lt;/p&gt;
&lt;p&gt;Querying remains straightforward:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-csharp&quot;&gt;var blogs = await context.Blogs
    .Where(b =&amp;gt; b.Details.Viewers &amp;gt; 3)
    .ToListAsync();
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;EF Core translates this into SQL using the appropriate JSON functions. For domains that already rely on JSON-like structures, this results in cleaner models and fewer mapping concerns.&lt;/p&gt;
&lt;h3 id=&quot;naming-default-constraints&quot;&gt;Naming default constraints&lt;/h3&gt;
&lt;p&gt;EF Core 10 allows explicitly naming default constraints instead of relying on database-generated names. This can help reduce unnecessary changes in migrations and make schema updates easier to track.&lt;/p&gt;
&lt;p&gt;Example:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-csharp&quot;&gt;modelBuilder.Entity&amp;lt;Post&amp;gt;()
    .Property(p =&amp;gt; p.CreatedDate)
    .HasDefaultValueSql(&quot;GETDATE()&quot;, &quot;DF_Post_CreatedDate&quot;);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;It’s also possible to enable automatic naming across the model:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-csharp&quot;&gt;modelBuilder.UseNamedDefaultConstraints();
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This change is mostly about maintainability, especially in projects with long migration histories.&lt;/p&gt;
&lt;h3 id=&quot;closing-thoughts&quot;&gt;Closing thoughts&lt;/h3&gt;
&lt;p&gt;EF Core 10 feels like a refinement release rather than a disruptive one. The added support for vector and JSON data types mainly improves how EF integrates with newer SQL Server features, while smaller changes like constraint naming help with long-term maintenance.&lt;/p&gt;
</description>
<category>Web Dev</category>
<guid isPermaLink="true">https://coderlegion.com/9100/sql-server-and-azure-sql-updates-with-ef-core-10</guid>
<pubDate>Tue, 30 Dec 2025 21:06:54 +0000</pubDate>
</item>
</channel>
</rss>