Skip to content

Commit fe85a6b

Browse files
authored
Docs related to version 7 GUID generation (#349)
Original commit: 2322a1a
1 parent a42ca36 commit fe85a6b

File tree

4 files changed

+181
-6
lines changed

4 files changed

+181
-6
lines changed

efcore/modeling/generated-properties.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -148,14 +148,14 @@ <h2 id="hilo-autoincrement-generation">HiLo Autoincrement Generation</h2>
148148
=&gt; modelBuilder.UseHiLo();
149149
</code></pre>
150150
<h2 id="guiduuid-generation">GUID/UUID Generation</h2>
151-
<p>By default, for GUID key properties, a random GUID is generated client-side by the EF provider and sent to the database.</p>
152-
<p>To generate GUID's client-side for non-key properties, configure them as follows:</p>
151+
<p>By default, for GUID key properties, a GUID is generated client-side by the EF provider and sent to the database. From version 9.0 and onwards, these GUIDs are sequential (version 7), which are more optimized for database indexes (before version 9.0, these GUIDs were random).</p>
152+
<p>To have the provider generate GUIDs client-side for <strong>non-key</strong> properties, configure them as follows:</p>
153153
<pre><code class="lang-c#">protected override void OnModelCreating(ModelBuilder modelBuilder)
154154
{
155155
modelBuilder
156156
.Entity&lt;Blog&gt;()
157157
.Property(b =&gt; b.SomeGuidProperty)
158-
.HasValueGenerator&lt;GuidValueGenerator&gt;();
158+
.HasValueGenerator&lt;NpgsqlSequentialGuidValueGenerator&gt;();
159159
}
160160
</code></pre>
161161
<p>If you prefer to generate values in the database instead, you can do so by specifying <code>HasDefaultValueSql</code> on your property, and call the function to generate the value in the SQL expression. Which function to use depends on your PostgreSQL version:</p>

efcore/release-notes/9.0.html

+158
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
<!DOCTYPE html>
2+
<!--[if IE]><![endif]-->
3+
<html>
4+
5+
<head>
6+
<meta charset="utf-8">
7+
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
8+
<title>9.0 Release Notes | Npgsql Documentation </title>
9+
<meta name="viewport" content="width=device-width">
10+
<meta name="title" content="9.0 Release Notes | Npgsql Documentation ">
11+
12+
<link rel="apple-touch-icon" sizes="180x180" href="../../apple-touch-icon.png">
13+
<link rel="icon" type="image/png" sizes="32x32" href="../../favicon-32x32.png">
14+
<link rel="icon" type="image/png" sizes="16x16" href="../../favicon-16x16.png">
15+
<link rel="manifest" href="../../site.webmanifest">
16+
<link rel="mask-icon" href="../../safari-pinned-tab.svg" color="#5bbad5">
17+
<meta name="msapplication-TileColor" content="#2b5797">
18+
<meta name="theme-color" content="#ffffff">
19+
<link rel="stylesheet" href="../../styles/docfx.vendor.css">
20+
<link rel="stylesheet" href="../../styles/docfx.css">
21+
<link rel="stylesheet" href="../../styles/main.css">
22+
<link rel="stylesheet" href="../../styles/npgsql.css">
23+
<meta property="docfx:navrel" content="../../toc.html">
24+
<meta property="docfx:tocrel" content="../toc.html">
25+
26+
<meta property="docfx:rel" content="../../">
27+
28+
</head>
29+
<body data-spy="scroll" data-target="#affix" data-offset="120">
30+
<div id="wrapper">
31+
<header>
32+
33+
<nav id="autocollapse" class="navbar navbar-inverse ng-scope" role="navigation">
34+
<div class="container">
35+
<div class="navbar-header">
36+
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar">
37+
<span class="sr-only">Toggle navigation</span>
38+
<span class="icon-bar"></span>
39+
<span class="icon-bar"></span>
40+
<span class="icon-bar"></span>
41+
</button>
42+
43+
<a class="navbar-brand" href="../../index.html">
44+
<img id="logo" class="svg" src="../../logo.svg" alt="">
45+
</a>
46+
</div>
47+
<div class="collapse navbar-collapse" id="navbar">
48+
<form class="navbar-form navbar-right" role="search" id="search">
49+
<div class="form-group">
50+
<input type="text" class="form-control" id="search-query" placeholder="Search" autocomplete="off">
51+
</div>
52+
</form>
53+
</div>
54+
</div>
55+
</nav>
56+
57+
<div class="subnav navbar navbar-default">
58+
<div class="container hide-when-search" id="breadcrumb">
59+
<ul class="breadcrumb">
60+
<li></li>
61+
</ul>
62+
</div>
63+
</div>
64+
</header>
65+
<div class="container body-content">
66+
67+
<div id="search-results">
68+
<div class="search-list">Search Results for <span></span></div>
69+
<div class="sr-items">
70+
<p><i class="glyphicon glyphicon-refresh index-loading"></i></p>
71+
</div>
72+
<ul id="pagination" data-first="First" data-prev="Previous" data-next="Next" data-last="Last"></ul>
73+
</div>
74+
</div>
75+
<div role="main" class="container body-content hide-when-search">
76+
77+
<div class="sidenav hide-when-search">
78+
<a class="btn toc-toggle collapse" data-toggle="collapse" href="#sidetoggle" aria-expanded="false" aria-controls="sidetoggle">Show / Hide Table of Contents</a>
79+
<div class="sidetoggle collapse" id="sidetoggle">
80+
<div id="sidetoc"></div>
81+
</div>
82+
</div>
83+
<div class="article row grid-right">
84+
<div class="col-md-10">
85+
<article class="content wrap" id="_content" data-uid="">
86+
<h1 id="90-release-notes">9.0 Release Notes</h1>
87+
88+
<p>Npgsql.EntityFrameworkCore.PostgreSQL version 9.0 is under development; previews are available on <a href="https://www.nuget.org/packages/Npgsql.EntityFrameworkCore.PostgreSQL">nuget.org</a>.</p>
89+
<h2 id="uuidv7-guids-are-generated-by-default">UUIDv7 GUIDs are generated by default</h2>
90+
<p>When your entity types have a <code>Guid</code> key, EF Core by default generates key values for new entities client-side - in .NET - before inserting those entity types to the database; this can be better for performance in some situations. Before version 9.0, the provider generated random GUIDs (version 4) by calling the .NET <a href="https://learn.microsoft.com/en-us/dotnet/api/system.guid.newguid?view=net-8.0#system-guid-newguid"><code>Guid.NewGuid()</code></a> function. Unfortunately, random GUIDs aren't ideal for database indexing and can cause performance issues.</p>
91+
<p>Version 9.0 of the provider now generates the recently standardized version 7 GUIDs, which is a sequential GUID type that's more appropriate for database indexes and improves their performance. This new behavior is by default and will take effect simply by upgrading the provider version.</p>
92+
<p>See <a href="https://www.cybertec-postgresql.com/en/unexpected-downsides-of-uuid-keys-in-postgresql">this post</a> for more details and performance numbers on random vs. sequential GUIDs.</p>
93+
<p>Thanks to <a href="https://github.com/ChrisJollyAU">@ChrisJollyAU</a> and <a href="https://github.com/Timovzl">@Timovzl</a> for contributing this improvement!</p>
94+
<h2 id="contributors">Contributors</h2>
95+
<p>A big thank you to all the following people who contributed to the 9.0 release!</p>
96+
<h3 id="milestone-900"><a href="https://github.com/npgsql/efcore.pg/milestone/61?closed=1">Milestone 9.0.0</a></h3>
97+
<table>
98+
<thead>
99+
<tr>
100+
<th>Contributor</th>
101+
<th>Assigned issues</th>
102+
</tr>
103+
</thead>
104+
<tbody>
105+
<tr>
106+
<td><a href="https://github.com/roji">@roji</a></td>
107+
<td><a href="https://github.com/Npgsql/efcore.pg/issues?q=is%3Aissue+milestone%3A8.0.0+is%3Aclosed+assignee%3Aroji">34</a></td>
108+
</tr>
109+
<tr>
110+
<td><a href="https://github.com/ChrisJollyAU">@ChrisJollyAU</a></td>
111+
<td><a href="https://github.com/Npgsql/efcore.pg/issues?q=is%3Aissue+milestone%3A8.0.0+is%3Aclosed+assignee%3AChrisJollyAU">1</a></td>
112+
</tr>
113+
<tr>
114+
<td><a href="https://github.com/Timovzl">@Timovzl</a></td>
115+
<td><a href="https://github.com/Npgsql/efcore.pg/issues?q=is%3Aissue+milestone%3A8.0.0+is%3Aclosed+assignee%3ATimovzl">1</a></td>
116+
</tr>
117+
</tbody>
118+
</table>
119+
</article>
120+
</div>
121+
122+
<div class="hidden-sm col-md-2" role="complementary">
123+
<div class="sideaffix">
124+
<div class="contribution">
125+
<ul class="nav">
126+
<li>
127+
<a href="https://github.com/npgsql/doc/blob/main/conceptual/EFCore.PG/release-notes/9.0.md/#L1" class="contribution-link">Improve this Doc</a>
128+
</li>
129+
</ul>
130+
</div>
131+
<nav class="bs-docs-sidebar hidden-print hidden-xs hidden-sm affix" id="affix">
132+
<h5>In This Article</h5>
133+
<div></div>
134+
</nav>
135+
</div>
136+
</div>
137+
</div>
138+
</div>
139+
140+
<footer>
141+
<div class="grad-bottom"></div>
142+
<div class="footer">
143+
<div class="container">
144+
<span class="pull-right">
145+
<a href="#top">Back to top</a>
146+
</span>
147+
© Copyright 2023 The Npgsql Development Team
148+
149+
</div>
150+
</div>
151+
</footer>
152+
</div>
153+
154+
<script type="text/javascript" src="../../styles/docfx.vendor.js"></script>
155+
<script type="text/javascript" src="../../styles/docfx.js"></script>
156+
<script type="text/javascript" src="../../styles/main.js"></script>
157+
</body>
158+
</html>

0 commit comments

Comments
 (0)