fix lecture 6 contents

main
borb 3 weeks ago
parent bb1f5fe3ad
commit 4b5e7d75b8

@ -13,20 +13,19 @@
/* buutti.css */ /* buutti.css */
/* @theme buutti */div#\:\$p>svg>foreignObject>section .columns{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:calc(var(--marpit-root-font-size, 1rem) * 1)}div#\:\$p>svg>foreignObject>section .columns12{display:grid;grid-template-columns:1fr 2fr;gap:calc(var(--marpit-root-font-size, 1rem) * 1)}div#\:\$p>svg>foreignObject>section .columns21{display:grid;grid-template-columns:2fr 1fr;gap:calc(var(--marpit-root-font-size, 1rem) * 1)}div#\:\$p>svg>foreignObject>section .columns32{display:grid;grid-template-columns:3fr 2fr;gap:calc(var(--marpit-root-font-size, 1rem) * 1)}div#\:\$p>svg>foreignObject>section .columns23{display:grid;grid-template-columns:2fr 3fr;gap:calc(var(--marpit-root-font-size, 1rem) * 1)}div#\:\$p>svg>foreignObject>section .columns111{display:grid;grid-template-columns:1fr 1fr 1fr;gap:calc(var(--marpit-root-font-size, 1rem) * 1)}div#\:\$p>svg>foreignObject>section .centered{display:flex;flex-direction:column;justify-content:center;text-align:center}div#\:\$p>svg>foreignObject>section .tableborderless td,div#\:\$p>svg>foreignObject>section th{border:none!important;border-collapse:collapse}div#\:\$p>svg>foreignObject>section.extra{background-color:#5d275d;background-image:linear-gradient(to bottom,#401a40,#1d0c1d);color:white}div#\:\$p>svg>foreignObject>section.extra a{color:rgb(145,255,209)}div#\:\$p>svg>foreignObject>section.exercise{background-color:#29366f;background-image:linear-gradient(to bottom,#20636a,#173742);color:white}div#\:\$p>svg>foreignObject>section.exercise a{color:rgb(211,173,255)} /* @theme buutti */div#\:\$p>svg>foreignObject>section .columns{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:calc(var(--marpit-root-font-size, 1rem) * 1)}div#\:\$p>svg>foreignObject>section .columns12{display:grid;grid-template-columns:1fr 2fr;gap:calc(var(--marpit-root-font-size, 1rem) * 1)}div#\:\$p>svg>foreignObject>section .columns21{display:grid;grid-template-columns:2fr 1fr;gap:calc(var(--marpit-root-font-size, 1rem) * 1)}div#\:\$p>svg>foreignObject>section .columns32{display:grid;grid-template-columns:3fr 2fr;gap:calc(var(--marpit-root-font-size, 1rem) * 1)}div#\:\$p>svg>foreignObject>section .columns23{display:grid;grid-template-columns:2fr 3fr;gap:calc(var(--marpit-root-font-size, 1rem) * 1)}div#\:\$p>svg>foreignObject>section .columns111{display:grid;grid-template-columns:1fr 1fr 1fr;gap:calc(var(--marpit-root-font-size, 1rem) * 1)}div#\:\$p>svg>foreignObject>section .centered{display:flex;flex-direction:column;justify-content:center;text-align:center}div#\:\$p>svg>foreignObject>section .tableborderless td,div#\:\$p>svg>foreignObject>section th{border:none!important;border-collapse:collapse}div#\:\$p>svg>foreignObject>section.extra{background-color:#5d275d;background-image:linear-gradient(to bottom,#401a40,#1d0c1d);color:white}div#\:\$p>svg>foreignObject>section.extra a{color:rgb(145,255,209)}div#\:\$p>svg>foreignObject>section.exercise{background-color:#29366f;background-image:linear-gradient(to bottom,#20636a,#173742);color:white}div#\:\$p>svg>foreignObject>section.exercise a{color:rgb(211,173,255)}
/* @theme qxwzalhzytjx5wnlf6losqvbl44tf0bt7if1oe7ch9 */div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background=background]{columns:initial!important;display:block!important;padding:0!important}div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background=background]:after,div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background=background]:before,div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background=content]:after,div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background=content]:before{display:none!important}div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background=background]>div[data-marpit-advanced-background-container]{all:initial;display:flex;flex-direction:row;height:100%;overflow:hidden;width:100%}div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background=background]>div[data-marpit-advanced-background-container][data-marpit-advanced-background-direction=vertical]{flex-direction:column}div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background=background][data-marpit-advanced-background-split]>div[data-marpit-advanced-background-container]{width:var(--marpit-advanced-background-split,50%)}div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background=background][data-marpit-advanced-background-split=right]>div[data-marpit-advanced-background-container]{margin-left:calc(100% - var(--marpit-advanced-background-split, 50%))}div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background=background]>div[data-marpit-advanced-background-container]>figure{all:initial;background-position:center;background-repeat:no-repeat;background-size:cover;flex:auto;margin:0}div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background=background]>div[data-marpit-advanced-background-container]>figure>figcaption{position:absolute;border:0;clip:rect(0,0,0,0);height:1px;margin:-1px;overflow:hidden;padding:0;white-space:nowrap;width:1px}div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background=content],div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background=pseudo]{background:transparent!important}div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background=pseudo],div#\:\$p>svg[data-marpit-svg]>foreignObject[data-marpit-advanced-background=pseudo]{pointer-events:none!important}div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background-split]{width:100%;height:100%}</style></head><body><div class="bespoke-marp-osc"><button data-bespoke-marp-osc="prev" tabindex="-1" title="Previous slide">Previous slide</button><span data-bespoke-marp-osc="page"></span><button data-bespoke-marp-osc="next" tabindex="-1" title="Next slide">Next slide</button><button data-bespoke-marp-osc="fullscreen" tabindex="-1" title="Toggle fullscreen (f)">Toggle fullscreen</button><button data-bespoke-marp-osc="presenter" tabindex="-1" title="Open presenter view (p)">Open presenter view</button></div><div id=":$p"><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="1" data-paginate="true" data-class="invert" data-heading-divider="5" data-theme="qxwzalhzytjx5wnlf6losqvbl44tf0bt7if1oe7ch9" lang="en-US" class="invert" data-marpit-pagination="1" style="--paginate:true;--class:invert;--heading-divider:5;--theme:qxwzalhzytjx5wnlf6losqvbl44tf0bt7if1oe7ch9;" data-marpit-pagination-total="38"> /* @theme ood9p0kg55vt1iq8tsdr2xnz4hx4dv18g1kl5unxk8 */div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background=background]{columns:initial!important;display:block!important;padding:0!important}div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background=background]:after,div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background=background]:before,div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background=content]:after,div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background=content]:before{display:none!important}div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background=background]>div[data-marpit-advanced-background-container]{all:initial;display:flex;flex-direction:row;height:100%;overflow:hidden;width:100%}div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background=background]>div[data-marpit-advanced-background-container][data-marpit-advanced-background-direction=vertical]{flex-direction:column}div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background=background][data-marpit-advanced-background-split]>div[data-marpit-advanced-background-container]{width:var(--marpit-advanced-background-split,50%)}div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background=background][data-marpit-advanced-background-split=right]>div[data-marpit-advanced-background-container]{margin-left:calc(100% - var(--marpit-advanced-background-split, 50%))}div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background=background]>div[data-marpit-advanced-background-container]>figure{all:initial;background-position:center;background-repeat:no-repeat;background-size:cover;flex:auto;margin:0}div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background=background]>div[data-marpit-advanced-background-container]>figure>figcaption{position:absolute;border:0;clip:rect(0,0,0,0);height:1px;margin:-1px;overflow:hidden;padding:0;white-space:nowrap;width:1px}div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background=content],div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background=pseudo]{background:transparent!important}div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background=pseudo],div#\:\$p>svg[data-marpit-svg]>foreignObject[data-marpit-advanced-background=pseudo]{pointer-events:none!important}div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background-split]{width:100%;height:100%}</style></head><body><div class="bespoke-marp-osc"><button data-bespoke-marp-osc="prev" tabindex="-1" title="Previous slide">Previous slide</button><span data-bespoke-marp-osc="page"></span><button data-bespoke-marp-osc="next" tabindex="-1" title="Next slide">Next slide</button><button data-bespoke-marp-osc="fullscreen" tabindex="-1" title="Toggle fullscreen (f)">Toggle fullscreen</button><button data-bespoke-marp-osc="presenter" tabindex="-1" title="Open presenter view (p)">Open presenter view</button></div><div id=":$p"><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="1" data-paginate="true" data-class="invert" data-heading-divider="5" data-theme="ood9p0kg55vt1iq8tsdr2xnz4hx4dv18g1kl5unxk8" lang="en-US" class="invert" data-marpit-pagination="1" style="--paginate:true;--class:invert;--heading-divider:5;--theme:ood9p0kg55vt1iq8tsdr2xnz4hx4dv18g1kl5unxk8;" data-marpit-pagination-total="38">
<h1 id="databases-with-entity-framework">Databases with Entity Framework</h1> <h1 id="databases-with-entity-framework">Databases with Entity Framework</h1>
</section> </section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="2" data-paginate="true" data-class="invert" data-heading-divider="5" data-theme="qxwzalhzytjx5wnlf6losqvbl44tf0bt7if1oe7ch9" lang="en-US" class="invert" data-marpit-pagination="2" style="--paginate:true;--class:invert;--heading-divider:5;--theme:qxwzalhzytjx5wnlf6losqvbl44tf0bt7if1oe7ch9;" data-marpit-pagination-total="38"> </foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="2" data-paginate="true" data-class="invert" data-heading-divider="5" data-theme="ood9p0kg55vt1iq8tsdr2xnz4hx4dv18g1kl5unxk8" lang="en-US" class="invert" data-marpit-pagination="2" style="--paginate:true;--class:invert;--heading-divider:5;--theme:ood9p0kg55vt1iq8tsdr2xnz4hx4dv18g1kl5unxk8;" data-marpit-pagination-total="38">
<h2 id="contents">Contents</h2> <h2 id="contents">Contents</h2>
<ul> <ul>
<li><a href="#entity-framework-ef">Entity Framework (EF)</a></li> <li><a href="#entity-framework-ef">Entity Framework (EF)</a></li>
<li><a href="#code-first-approach">Code First approach</a></li> <li><a href="#code-first-approach">Code First approach</a></li>
<li><a href="#migrations">Migrations</a></li> <li><a href="#migrations">Migrations</a></li>
<li><a href="#migrations">Migrations</a></li>
<li><a href="#database-first-approach">Database First approach</a></li> <li><a href="#database-first-approach">Database First approach</a></li>
</ul> </ul>
</section> </section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="3" data-marpit-fragments="5" data-paginate="true" data-class="invert" data-heading-divider="5" data-theme="qxwzalhzytjx5wnlf6losqvbl44tf0bt7if1oe7ch9" lang="en-US" class="invert" data-marpit-pagination="3" style="--paginate:true;--class:invert;--heading-divider:5;--theme:qxwzalhzytjx5wnlf6losqvbl44tf0bt7if1oe7ch9;" data-marpit-pagination-total="38"> </foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="3" data-marpit-fragments="5" data-paginate="true" data-class="invert" data-heading-divider="5" data-theme="ood9p0kg55vt1iq8tsdr2xnz4hx4dv18g1kl5unxk8" lang="en-US" class="invert" data-marpit-pagination="3" style="--paginate:true;--class:invert;--heading-divider:5;--theme:ood9p0kg55vt1iq8tsdr2xnz4hx4dv18g1kl5unxk8;" data-marpit-pagination-total="38">
<h2 id="entity-framework-ef">Entity Framework (EF)</h2> <h2 id="entity-framework-ef">Entity Framework (EF)</h2>
<ul> <ul>
<li data-marpit-fragment="1">This lecture will assume you have a basic understanding of SQL databases <li data-marpit-fragment="1">This lecture will assume you have a basic understanding of SQL databases
@ -42,7 +41,7 @@
<li data-marpit-fragment="5">Allows creation of CRUD operations without writing SQL</li> <li data-marpit-fragment="5">Allows creation of CRUD operations without writing SQL</li>
</ul> </ul>
</section> </section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="4" data-marpit-fragments="5" data-paginate="true" data-class="invert" data-heading-divider="5" data-theme="qxwzalhzytjx5wnlf6losqvbl44tf0bt7if1oe7ch9" lang="en-US" class="invert" data-marpit-pagination="4" style="--paginate:true;--class:invert;--heading-divider:5;--theme:qxwzalhzytjx5wnlf6losqvbl44tf0bt7if1oe7ch9;" data-marpit-pagination-total="38"> </foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="4" data-marpit-fragments="5" data-paginate="true" data-class="invert" data-heading-divider="5" data-theme="ood9p0kg55vt1iq8tsdr2xnz4hx4dv18g1kl5unxk8" lang="en-US" class="invert" data-marpit-pagination="4" style="--paginate:true;--class:invert;--heading-divider:5;--theme:ood9p0kg55vt1iq8tsdr2xnz4hx4dv18g1kl5unxk8;" data-marpit-pagination-total="38">
<h3 id="entity-framework-core-ef-core">Entity Framework Core (EF Core)</h3> <h3 id="entity-framework-core-ef-core">Entity Framework Core (EF Core)</h3>
<ul> <ul>
<li data-marpit-fragment="1"><a href="https://learn.microsoft.com/en-us/ef/core/">EF Core</a> is a cross-platform version of EF</li> <li data-marpit-fragment="1"><a href="https://learn.microsoft.com/en-us/ef/core/">EF Core</a> is a cross-platform version of EF</li>
@ -52,7 +51,7 @@
<li data-marpit-fragment="5">This is what we'll be using</li> <li data-marpit-fragment="5">This is what we'll be using</li>
</ul> </ul>
</section> </section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="5" data-marpit-fragments="5" data-paginate="true" data-class="invert" data-heading-divider="5" data-theme="qxwzalhzytjx5wnlf6losqvbl44tf0bt7if1oe7ch9" lang="en-US" class="invert" data-marpit-pagination="5" style="--paginate:true;--class:invert;--heading-divider:5;--theme:qxwzalhzytjx5wnlf6losqvbl44tf0bt7if1oe7ch9;" data-marpit-pagination-total="38"> </foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="5" data-marpit-fragments="5" data-paginate="true" data-class="invert" data-heading-divider="5" data-theme="ood9p0kg55vt1iq8tsdr2xnz4hx4dv18g1kl5unxk8" lang="en-US" class="invert" data-marpit-pagination="5" style="--paginate:true;--class:invert;--heading-divider:5;--theme:ood9p0kg55vt1iq8tsdr2xnz4hx4dv18g1kl5unxk8;" data-marpit-pagination-total="38">
<h3 id="code-first-vs-database-first-vs-model-first">Code First vs Database First vs Model First</h3> <h3 id="code-first-vs-database-first-vs-model-first">Code First vs Database First vs Model First</h3>
<ul> <ul>
<li data-marpit-fragment="1">There are three approaches through which Entity Framework can be implemented <li data-marpit-fragment="1">There are three approaches through which Entity Framework can be implemented
@ -65,7 +64,7 @@
<li data-marpit-fragment="5">Database First and Code First are the most used ones and will be introduced in this lecture</li> <li data-marpit-fragment="5">Database First and Code First are the most used ones and will be introduced in this lecture</li>
</ul> </ul>
</section> </section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="6" data-marpit-fragments="5" data-paginate="true" data-class="invert" data-heading-divider="5" data-theme="qxwzalhzytjx5wnlf6losqvbl44tf0bt7if1oe7ch9" lang="en-US" class="invert" data-marpit-pagination="6" style="--paginate:true;--class:invert;--heading-divider:5;--theme:qxwzalhzytjx5wnlf6losqvbl44tf0bt7if1oe7ch9;" data-marpit-pagination-total="38"> </foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="6" data-marpit-fragments="5" data-paginate="true" data-class="invert" data-heading-divider="5" data-theme="ood9p0kg55vt1iq8tsdr2xnz4hx4dv18g1kl5unxk8" lang="en-US" class="invert" data-marpit-pagination="6" style="--paginate:true;--class:invert;--heading-divider:5;--theme:ood9p0kg55vt1iq8tsdr2xnz4hx4dv18g1kl5unxk8;" data-marpit-pagination-total="38">
<h3 id="note-about-loading-data">Note about loading data</h3> <h3 id="note-about-loading-data">Note about loading data</h3>
<ul> <ul>
<li data-marpit-fragment="1">In EF Core, you can use <a href="https://learn.microsoft.com/en-us/ef/ef6/fundamentals/relationships">navigation properties</a> in your model to load related entities</li> <li data-marpit-fragment="1">In EF Core, you can use <a href="https://learn.microsoft.com/en-us/ef/ef6/fundamentals/relationships">navigation properties</a> in your model to load related entities</li>
@ -78,10 +77,10 @@
</li> </li>
</ul> </ul>
</section> </section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="7" data-paginate="true" data-class="invert" data-heading-divider="5" data-theme="qxwzalhzytjx5wnlf6losqvbl44tf0bt7if1oe7ch9" lang="en-US" class="invert" data-marpit-pagination="7" style="--paginate:true;--class:invert;--heading-divider:5;--theme:qxwzalhzytjx5wnlf6losqvbl44tf0bt7if1oe7ch9;" data-marpit-pagination-total="38"> </foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="7" data-paginate="true" data-class="invert" data-heading-divider="5" data-theme="ood9p0kg55vt1iq8tsdr2xnz4hx4dv18g1kl5unxk8" lang="en-US" class="invert" data-marpit-pagination="7" style="--paginate:true;--class:invert;--heading-divider:5;--theme:ood9p0kg55vt1iq8tsdr2xnz4hx4dv18g1kl5unxk8;" data-marpit-pagination-total="38">
<h2 id="code-first-approach">Code First approach</h2> <h2 id="code-first-approach">Code First approach</h2>
</section> </section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="8" data-marpit-fragments="9" data-paginate="true" data-class="invert" data-heading-divider="5" data-theme="qxwzalhzytjx5wnlf6losqvbl44tf0bt7if1oe7ch9" lang="en-US" class="invert" data-marpit-pagination="8" style="--paginate:true;--class:invert;--heading-divider:5;--theme:qxwzalhzytjx5wnlf6losqvbl44tf0bt7if1oe7ch9;" data-marpit-pagination-total="38"> </foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="8" data-marpit-fragments="9" data-paginate="true" data-class="invert" data-heading-divider="5" data-theme="ood9p0kg55vt1iq8tsdr2xnz4hx4dv18g1kl5unxk8" lang="en-US" class="invert" data-marpit-pagination="8" style="--paginate:true;--class:invert;--heading-divider:5;--theme:ood9p0kg55vt1iq8tsdr2xnz4hx4dv18g1kl5unxk8;" data-marpit-pagination-total="38">
<h3 id="code-first">Code First</h3> <h3 id="code-first">Code First</h3>
<ul> <ul>
<li data-marpit-fragment="1">In the Code First approach, Entity Framework will create databases and tables based on defined <em><strong>entity classes</strong></em></li> <li data-marpit-fragment="1">In the Code First approach, Entity Framework will create databases and tables based on defined <em><strong>entity classes</strong></em></li>
@ -101,7 +100,7 @@
<li data-marpit-fragment="9">Not preferred for data intensive applications</li> <li data-marpit-fragment="9">Not preferred for data intensive applications</li>
</ul> </ul>
</section> </section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="9" data-marpit-fragments="4" data-paginate="true" data-class="invert" data-heading-divider="5" data-theme="qxwzalhzytjx5wnlf6losqvbl44tf0bt7if1oe7ch9" lang="en-US" class="invert" data-marpit-pagination="9" style="--paginate:true;--class:invert;--heading-divider:5;--theme:qxwzalhzytjx5wnlf6losqvbl44tf0bt7if1oe7ch9;" data-marpit-pagination-total="38"> </foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="9" data-marpit-fragments="4" data-paginate="true" data-class="invert" data-heading-divider="5" data-theme="ood9p0kg55vt1iq8tsdr2xnz4hx4dv18g1kl5unxk8" lang="en-US" class="invert" data-marpit-pagination="9" style="--paginate:true;--class:invert;--heading-divider:5;--theme:ood9p0kg55vt1iq8tsdr2xnz4hx4dv18g1kl5unxk8;" data-marpit-pagination-total="38">
<h3 id="required-packages">Required Packages</h3> <h3 id="required-packages">Required Packages</h3>
<ul> <ul>
<li data-marpit-fragment="1">Install and add the following packages to your project: <li data-marpit-fragment="1">Install and add the following packages to your project:
@ -116,7 +115,7 @@
<p><img src="imgs/7-databases-with-entity-framework_11.png" alt="" style="width:1000px;" /></p> <p><img src="imgs/7-databases-with-entity-framework_11.png" alt="" style="width:1000px;" /></p>
</div> </div>
</section> </section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="10" data-marpit-fragments="5" data-paginate="true" data-class="invert" data-heading-divider="5" data-theme="qxwzalhzytjx5wnlf6losqvbl44tf0bt7if1oe7ch9" lang="en-US" class="invert" data-marpit-pagination="10" style="--paginate:true;--class:invert;--heading-divider:5;--theme:qxwzalhzytjx5wnlf6losqvbl44tf0bt7if1oe7ch9;" data-marpit-pagination-total="38"> </foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="10" data-marpit-fragments="5" data-paginate="true" data-class="invert" data-heading-divider="5" data-theme="ood9p0kg55vt1iq8tsdr2xnz4hx4dv18g1kl5unxk8" lang="en-US" class="invert" data-marpit-pagination="10" style="--paginate:true;--class:invert;--heading-divider:5;--theme:ood9p0kg55vt1iq8tsdr2xnz4hx4dv18g1kl5unxk8;" data-marpit-pagination-total="38">
<h3 id="code-first-dbcontext">Code First: <code>DbContext</code></h3> <h3 id="code-first-dbcontext">Code First: <code>DbContext</code></h3>
<ul> <ul>
<li data-marpit-fragment="1">Let's begin with the Code First Approach</li> <li data-marpit-fragment="1">Let's begin with the Code First Approach</li>
@ -131,7 +130,7 @@ b) classes to keep the database up-to-date with CRUD operations
</li> </li>
</ul> </ul>
</section> </section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="11" data-marpit-fragments="4" data-paginate="true" data-class="invert" data-heading-divider="5" data-theme="qxwzalhzytjx5wnlf6losqvbl44tf0bt7if1oe7ch9" lang="en-US" class="invert" data-marpit-pagination="11" style="--paginate:true;--class:invert;--heading-divider:5;--theme:qxwzalhzytjx5wnlf6losqvbl44tf0bt7if1oe7ch9;" data-marpit-pagination-total="38"> </foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="11" data-marpit-fragments="4" data-paginate="true" data-class="invert" data-heading-divider="5" data-theme="ood9p0kg55vt1iq8tsdr2xnz4hx4dv18g1kl5unxk8" lang="en-US" class="invert" data-marpit-pagination="11" style="--paginate:true;--class:invert;--heading-divider:5;--theme:ood9p0kg55vt1iq8tsdr2xnz4hx4dv18g1kl5unxk8;" data-marpit-pagination-total="38">
<h3 id="creating-a-context">Creating a context</h3> <h3 id="creating-a-context">Creating a context</h3>
<ul> <ul>
<li data-marpit-fragment="1">Create a context that inherits from <code>DbContext</code> <li data-marpit-fragment="1">Create a context that inherits from <code>DbContext</code>
@ -151,7 +150,7 @@ b) classes to keep the database up-to-date with CRUD operations
</li> </li>
</ul> </ul>
</section> </section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="12" data-marpit-fragments="2" data-paginate="true" data-class="invert" data-heading-divider="5" data-theme="qxwzalhzytjx5wnlf6losqvbl44tf0bt7if1oe7ch9" lang="en-US" class="invert" data-marpit-pagination="12" style="--paginate:true;--class:invert;--heading-divider:5;--theme:qxwzalhzytjx5wnlf6losqvbl44tf0bt7if1oe7ch9;" data-marpit-pagination-total="38"> </foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="12" data-marpit-fragments="2" data-paginate="true" data-class="invert" data-heading-divider="5" data-theme="ood9p0kg55vt1iq8tsdr2xnz4hx4dv18g1kl5unxk8" lang="en-US" class="invert" data-marpit-pagination="12" style="--paginate:true;--class:invert;--heading-divider:5;--theme:ood9p0kg55vt1iq8tsdr2xnz4hx4dv18g1kl5unxk8;" data-marpit-pagination-total="38">
<ul> <ul>
<li data-marpit-fragment="1">To further configure how the database will be structured, override the <code>OnModelCreating</code> method</li> <li data-marpit-fragment="1">To further configure how the database will be structured, override the <code>OnModelCreating</code> method</li>
<li data-marpit-fragment="2">In this example, one table named <code>Contact</code> with columns <code>Id</code>, <code>Name</code> and <code>Email</code> will be created:<pre is="marp-pre" data-auto-scaling="downscale-only"><code class="language-csharp"><span class="hljs-keyword">public</span> <span class="hljs-keyword">class</span> <span class="hljs-title">ContactsContext</span> : <span class="hljs-title">DbContext</span> <li data-marpit-fragment="2">In this example, one table named <code>Contact</code> with columns <code>Id</code>, <code>Name</code> and <code>Email</code> will be created:<pre is="marp-pre" data-auto-scaling="downscale-only"><code class="language-csharp"><span class="hljs-keyword">public</span> <span class="hljs-keyword">class</span> <span class="hljs-title">ContactsContext</span> : <span class="hljs-title">DbContext</span>
@ -168,7 +167,7 @@ b) classes to keep the database up-to-date with CRUD operations
</li> </li>
</ul> </ul>
</section> </section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="13" data-marpit-fragments="1" data-paginate="true" data-class="invert" data-heading-divider="5" data-theme="qxwzalhzytjx5wnlf6losqvbl44tf0bt7if1oe7ch9" lang="en-US" class="invert" data-marpit-pagination="13" style="--paginate:true;--class:invert;--heading-divider:5;--theme:qxwzalhzytjx5wnlf6losqvbl44tf0bt7if1oe7ch9;" data-marpit-pagination-total="38"> </foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="13" data-marpit-fragments="1" data-paginate="true" data-class="invert" data-heading-divider="5" data-theme="ood9p0kg55vt1iq8tsdr2xnz4hx4dv18g1kl5unxk8" lang="en-US" class="invert" data-marpit-pagination="13" style="--paginate:true;--class:invert;--heading-divider:5;--theme:ood9p0kg55vt1iq8tsdr2xnz4hx4dv18g1kl5unxk8;" data-marpit-pagination-total="38">
<ul> <ul>
<li data-marpit-fragment="1">In this example, the Contact table will be created with some starting values for <code>Id</code>, <code>Name</code> and <code>Email</code> columns:<pre is="marp-pre" data-auto-scaling="downscale-only"><code class="language-csharp"><span class="hljs-keyword">public</span> <span class="hljs-keyword">class</span> <span class="hljs-title">ContactsContext</span> : <span class="hljs-title">DbContext</span> <li data-marpit-fragment="1">In this example, the Contact table will be created with some starting values for <code>Id</code>, <code>Name</code> and <code>Email</code> columns:<pre is="marp-pre" data-auto-scaling="downscale-only"><code class="language-csharp"><span class="hljs-keyword">public</span> <span class="hljs-keyword">class</span> <span class="hljs-title">ContactsContext</span> : <span class="hljs-title">DbContext</span>
{ {
@ -187,7 +186,7 @@ b) classes to keep the database up-to-date with CRUD operations
</li> </li>
</ul> </ul>
</section> </section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="14" data-marpit-fragments="4" data-paginate="true" data-class="invert" data-heading-divider="5" data-theme="qxwzalhzytjx5wnlf6losqvbl44tf0bt7if1oe7ch9" lang="en-US" class="invert" data-marpit-pagination="14" style="--paginate:true;--class:invert;--heading-divider:5;--theme:qxwzalhzytjx5wnlf6losqvbl44tf0bt7if1oe7ch9;" data-marpit-pagination-total="38"> </foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="14" data-marpit-fragments="4" data-paginate="true" data-class="invert" data-heading-divider="5" data-theme="ood9p0kg55vt1iq8tsdr2xnz4hx4dv18g1kl5unxk8" lang="en-US" class="invert" data-marpit-pagination="14" style="--paginate:true;--class:invert;--heading-divider:5;--theme:ood9p0kg55vt1iq8tsdr2xnz4hx4dv18g1kl5unxk8;" data-marpit-pagination-total="38">
<h3 id="dbcontext-as-a-service">DbContext as a Service</h3> <h3 id="dbcontext-as-a-service">DbContext as a Service</h3>
<ul> <ul>
<li data-marpit-fragment="1">In <code>Program.cs</code>, add the context to services with <code>AddDbContext</code> method</li> <li data-marpit-fragment="1">In <code>Program.cs</code>, add the context to services with <code>AddDbContext</code> method</li>
@ -204,7 +203,7 @@ services.AddControllers().AddNewtonsoftJson();
</li> </li>
</ul> </ul>
</section> </section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="15" data-marpit-fragments="5" data-paginate="true" data-class="invert" data-heading-divider="5" data-theme="qxwzalhzytjx5wnlf6losqvbl44tf0bt7if1oe7ch9" lang="en-US" class="invert" data-marpit-pagination="15" style="--paginate:true;--class:invert;--heading-divider:5;--theme:qxwzalhzytjx5wnlf6losqvbl44tf0bt7if1oe7ch9;" data-marpit-pagination-total="38"> </foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="15" data-marpit-fragments="5" data-paginate="true" data-class="invert" data-heading-divider="5" data-theme="ood9p0kg55vt1iq8tsdr2xnz4hx4dv18g1kl5unxk8" lang="en-US" class="invert" data-marpit-pagination="15" style="--paginate:true;--class:invert;--heading-divider:5;--theme:ood9p0kg55vt1iq8tsdr2xnz4hx4dv18g1kl5unxk8;" data-marpit-pagination-total="38">
<h2 id="migrations">Migrations</h2> <h2 id="migrations">Migrations</h2>
<ul> <ul>
<li data-marpit-fragment="1">As the development progresses, models and database schemas change over time <li data-marpit-fragment="1">As the development progresses, models and database schemas change over time
@ -220,7 +219,7 @@ services.AddControllers().AddNewtonsoftJson();
<li data-marpit-fragment="5">EFCore migrations have built-in version control; a snapshot of each version of the schema is stored</li> <li data-marpit-fragment="5">EFCore migrations have built-in version control; a snapshot of each version of the schema is stored</li>
</ul> </ul>
</section> </section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="16" data-marpit-fragments="6" data-paginate="true" data-class="invert" data-heading-divider="5" data-theme="qxwzalhzytjx5wnlf6losqvbl44tf0bt7if1oe7ch9" lang="en-US" class="invert" data-marpit-pagination="16" style="--paginate:true;--class:invert;--heading-divider:5;--theme:qxwzalhzytjx5wnlf6losqvbl44tf0bt7if1oe7ch9;" data-marpit-pagination-total="38"> </foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="16" data-marpit-fragments="6" data-paginate="true" data-class="invert" data-heading-divider="5" data-theme="ood9p0kg55vt1iq8tsdr2xnz4hx4dv18g1kl5unxk8" lang="en-US" class="invert" data-marpit-pagination="16" style="--paginate:true;--class:invert;--heading-divider:5;--theme:ood9p0kg55vt1iq8tsdr2xnz4hx4dv18g1kl5unxk8;" data-marpit-pagination-total="38">
<h3 id="applying-migrations">Applying migrations</h3> <h3 id="applying-migrations">Applying migrations</h3>
<ul> <ul>
<li data-marpit-fragment="1">Open the Package Manager Console in Visual Studio <li data-marpit-fragment="1">Open the Package Manager Console in Visual Studio
@ -241,7 +240,7 @@ services.AddControllers().AddNewtonsoftJson();
</li> </li>
</ul> </ul>
</section> </section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="17" data-marpit-fragments="3" data-paginate="true" data-class="invert" data-heading-divider="5" data-theme="qxwzalhzytjx5wnlf6losqvbl44tf0bt7if1oe7ch9" lang="en-US" class="invert" data-marpit-pagination="17" style="--paginate:true;--class:invert;--heading-divider:5;--theme:qxwzalhzytjx5wnlf6losqvbl44tf0bt7if1oe7ch9;" data-marpit-pagination-total="38"> </foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="17" data-marpit-fragments="3" data-paginate="true" data-class="invert" data-heading-divider="5" data-theme="ood9p0kg55vt1iq8tsdr2xnz4hx4dv18g1kl5unxk8" lang="en-US" class="invert" data-marpit-pagination="17" style="--paginate:true;--class:invert;--heading-divider:5;--theme:ood9p0kg55vt1iq8tsdr2xnz4hx4dv18g1kl5unxk8;" data-marpit-pagination-total="38">
<ul> <ul>
<li data-marpit-fragment="1">At this point, the values you have entered (<code>Contacts</code> table in this example) should show up in the database. You can check it up e.g. in pgAdmin.</li> <li data-marpit-fragment="1">At this point, the values you have entered (<code>Contacts</code> table in this example) should show up in the database. You can check it up e.g. in pgAdmin.</li>
</ul> </ul>
@ -262,7 +261,7 @@ services.AddControllers().AddNewtonsoftJson();
</li> </li>
</ul> </ul>
</section> </section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="18" data-marpit-fragments="6" data-paginate="true" data-class="exercise invert" data-heading-divider="5" data-theme="qxwzalhzytjx5wnlf6losqvbl44tf0bt7if1oe7ch9" lang="en-US" class="exercise invert" data-marpit-pagination="18" style="--paginate:true;--class:exercise invert;--heading-divider:5;--theme:qxwzalhzytjx5wnlf6losqvbl44tf0bt7if1oe7ch9;" data-marpit-pagination-total="38"> </foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="18" data-marpit-fragments="6" data-paginate="true" data-class="exercise invert" data-heading-divider="5" data-theme="ood9p0kg55vt1iq8tsdr2xnz4hx4dv18g1kl5unxk8" lang="en-US" class="exercise invert" data-marpit-pagination="18" style="--paginate:true;--class:exercise invert;--heading-divider:5;--theme:ood9p0kg55vt1iq8tsdr2xnz4hx4dv18g1kl5unxk8;" data-marpit-pagination-total="38">
<h3 id="exercise-1-adding-context">Exercise 1: Adding Context</h3> <h3 id="exercise-1-adding-context">Exercise 1: Adding Context</h3>
<p>Continue working on the CourseAPI.</p> <p>Continue working on the CourseAPI.</p>
@ -275,7 +274,7 @@ services.AddControllers().AddNewtonsoftJson();
<li data-marpit-fragment="6">Check that the <code>Course</code> table with the starting values has appeared to the database</li> <li data-marpit-fragment="6">Check that the <code>Course</code> table with the starting values has appeared to the database</li>
</ol> </ol>
</section> </section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="19" data-marpit-fragments="6" data-paginate="true" data-class="invert" data-heading-divider="5" data-theme="qxwzalhzytjx5wnlf6losqvbl44tf0bt7if1oe7ch9" lang="en-US" class="invert" data-marpit-pagination="19" style="--paginate:true;--class:invert;--heading-divider:5;--theme:qxwzalhzytjx5wnlf6losqvbl44tf0bt7if1oe7ch9;" data-marpit-pagination-total="38"> </foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="19" data-marpit-fragments="6" data-paginate="true" data-class="invert" data-heading-divider="5" data-theme="ood9p0kg55vt1iq8tsdr2xnz4hx4dv18g1kl5unxk8" lang="en-US" class="invert" data-marpit-pagination="19" style="--paginate:true;--class:invert;--heading-divider:5;--theme:ood9p0kg55vt1iq8tsdr2xnz4hx4dv18g1kl5unxk8;" data-marpit-pagination-total="38">
<h3 id="using-dbcontext-in-the-api">Using DbContext in the API</h3> <h3 id="using-dbcontext-in-the-api">Using DbContext in the API</h3>
<ul> <ul>
<li data-marpit-fragment="1">Because <code>DbContext</code> is added to services, it can be accessed from any other service, such as the repository</li> <li data-marpit-fragment="1">Because <code>DbContext</code> is added to services, it can be accessed from any other service, such as the repository</li>
@ -289,7 +288,7 @@ services.AddControllers().AddNewtonsoftJson();
<li data-marpit-fragment="6">After modifying the <code>DbSet</code>, update the changes to the database with the <code>DbContext.SaveChanges()</code> method</li> <li data-marpit-fragment="6">After modifying the <code>DbSet</code>, update the changes to the database with the <code>DbContext.SaveChanges()</code> method</li>
</ul> </ul>
</section> </section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="20" data-marpit-fragments="1" data-paginate="true" data-class="invert" data-heading-divider="5" data-theme="qxwzalhzytjx5wnlf6losqvbl44tf0bt7if1oe7ch9" lang="en-US" class="invert" data-marpit-pagination="20" style="--paginate:true;--class:invert;--heading-divider:5;--theme:qxwzalhzytjx5wnlf6losqvbl44tf0bt7if1oe7ch9;" data-marpit-pagination-total="38"> </foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="20" data-marpit-fragments="1" data-paginate="true" data-class="invert" data-heading-divider="5" data-theme="ood9p0kg55vt1iq8tsdr2xnz4hx4dv18g1kl5unxk8" lang="en-US" class="invert" data-marpit-pagination="20" style="--paginate:true;--class:invert;--heading-divider:5;--theme:ood9p0kg55vt1iq8tsdr2xnz4hx4dv18g1kl5unxk8;" data-marpit-pagination-total="38">
<h3 id="injecting-dbcontext">Injecting DbContext</h3> <h3 id="injecting-dbcontext">Injecting DbContext</h3>
<ul> <ul>
<li data-marpit-fragment="1">Inject the <code>DbContext</code> to your repositories as you would any other service:<pre is="marp-pre" data-auto-scaling="downscale-only"><code class="language-csharp"><span class="hljs-keyword">public</span> <span class="hljs-keyword">class</span> <span class="hljs-title">ContactRepository</span> : <span class="hljs-title">IContactRepository</span> <li data-marpit-fragment="1">Inject the <code>DbContext</code> to your repositories as you would any other service:<pre is="marp-pre" data-auto-scaling="downscale-only"><code class="language-csharp"><span class="hljs-keyword">public</span> <span class="hljs-keyword">class</span> <span class="hljs-title">ContactRepository</span> : <span class="hljs-title">IContactRepository</span>
@ -306,7 +305,7 @@ services.AddControllers().AddNewtonsoftJson();
</li> </li>
</ul> </ul>
</section> </section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="21" data-paginate="true" data-class="invert" data-heading-divider="5" data-theme="qxwzalhzytjx5wnlf6losqvbl44tf0bt7if1oe7ch9" lang="en-US" class="invert" data-marpit-pagination="21" style="--paginate:true;--class:invert;--heading-divider:5;--theme:qxwzalhzytjx5wnlf6losqvbl44tf0bt7if1oe7ch9;" data-marpit-pagination-total="38"> </foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="21" data-paginate="true" data-class="invert" data-heading-divider="5" data-theme="ood9p0kg55vt1iq8tsdr2xnz4hx4dv18g1kl5unxk8" lang="en-US" class="invert" data-marpit-pagination="21" style="--paginate:true;--class:invert;--heading-divider:5;--theme:ood9p0kg55vt1iq8tsdr2xnz4hx4dv18g1kl5unxk8;" data-marpit-pagination-total="38">
<h3 id="dbcontext-read-operations">DbContext: Read Operations</h3> <h3 id="dbcontext-read-operations">DbContext: Read Operations</h3>
<pre is="marp-pre" data-auto-scaling="downscale-only"><code class="language-csharp"><span class="hljs-keyword">public</span> <span class="hljs-keyword">class</span> <span class="hljs-title">ContactRepository</span> : <span class="hljs-title">IContactRepository</span> <pre is="marp-pre" data-auto-scaling="downscale-only"><code class="language-csharp"><span class="hljs-keyword">public</span> <span class="hljs-keyword">class</span> <span class="hljs-title">ContactRepository</span> : <span class="hljs-title">IContactRepository</span>
{ {
@ -321,7 +320,7 @@ services.AddControllers().AddNewtonsoftJson();
} }
</code></pre> </code></pre>
</section> </section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="22" data-paginate="true" data-class="invert" data-heading-divider="5" data-theme="qxwzalhzytjx5wnlf6losqvbl44tf0bt7if1oe7ch9" lang="en-US" class="invert" data-marpit-pagination="22" style="--paginate:true;--class:invert;--heading-divider:5;--theme:qxwzalhzytjx5wnlf6losqvbl44tf0bt7if1oe7ch9;" data-marpit-pagination-total="38"> </foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="22" data-paginate="true" data-class="invert" data-heading-divider="5" data-theme="ood9p0kg55vt1iq8tsdr2xnz4hx4dv18g1kl5unxk8" lang="en-US" class="invert" data-marpit-pagination="22" style="--paginate:true;--class:invert;--heading-divider:5;--theme:ood9p0kg55vt1iq8tsdr2xnz4hx4dv18g1kl5unxk8;" data-marpit-pagination-total="38">
<h3 id="dbcontext-create-operations">DbContext: Create Operations</h3> <h3 id="dbcontext-create-operations">DbContext: Create Operations</h3>
<pre is="marp-pre" data-auto-scaling="downscale-only"><code class="language-csharp"><span class="hljs-keyword">public</span> <span class="hljs-keyword">class</span> <span class="hljs-title">ContactRepository</span> : <span class="hljs-title">IContactRepository</span> <pre is="marp-pre" data-auto-scaling="downscale-only"><code class="language-csharp"><span class="hljs-keyword">public</span> <span class="hljs-keyword">class</span> <span class="hljs-title">ContactRepository</span> : <span class="hljs-title">IContactRepository</span>
{ {
@ -339,7 +338,7 @@ services.AddControllers().AddNewtonsoftJson();
} }
</code></pre> </code></pre>
</section> </section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="23" data-paginate="true" data-class="invert" data-heading-divider="5" data-theme="qxwzalhzytjx5wnlf6losqvbl44tf0bt7if1oe7ch9" lang="en-US" class="invert" data-marpit-pagination="23" style="--paginate:true;--class:invert;--heading-divider:5;--theme:qxwzalhzytjx5wnlf6losqvbl44tf0bt7if1oe7ch9;" data-marpit-pagination-total="38"> </foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="23" data-paginate="true" data-class="invert" data-heading-divider="5" data-theme="ood9p0kg55vt1iq8tsdr2xnz4hx4dv18g1kl5unxk8" lang="en-US" class="invert" data-marpit-pagination="23" style="--paginate:true;--class:invert;--heading-divider:5;--theme:ood9p0kg55vt1iq8tsdr2xnz4hx4dv18g1kl5unxk8;" data-marpit-pagination-total="38">
<h3 id="dbcontext-update-operations">DbContext: Update Operations</h3> <h3 id="dbcontext-update-operations">DbContext: Update Operations</h3>
<pre is="marp-pre" data-auto-scaling="downscale-only"><code class="language-csharp"><span class="hljs-keyword">public</span> <span class="hljs-keyword">class</span> <span class="hljs-title">ContactRepository</span> : <span class="hljs-title">IContactRepository</span> <pre is="marp-pre" data-auto-scaling="downscale-only"><code class="language-csharp"><span class="hljs-keyword">public</span> <span class="hljs-keyword">class</span> <span class="hljs-title">ContactRepository</span> : <span class="hljs-title">IContactRepository</span>
{ {
@ -360,7 +359,7 @@ services.AddControllers().AddNewtonsoftJson();
} }
</code></pre> </code></pre>
</section> </section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="24" data-paginate="true" data-class="invert" data-heading-divider="5" data-theme="qxwzalhzytjx5wnlf6losqvbl44tf0bt7if1oe7ch9" lang="en-US" class="invert" data-marpit-pagination="24" style="--paginate:true;--class:invert;--heading-divider:5;--theme:qxwzalhzytjx5wnlf6losqvbl44tf0bt7if1oe7ch9;" data-marpit-pagination-total="38"> </foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="24" data-paginate="true" data-class="invert" data-heading-divider="5" data-theme="ood9p0kg55vt1iq8tsdr2xnz4hx4dv18g1kl5unxk8" lang="en-US" class="invert" data-marpit-pagination="24" style="--paginate:true;--class:invert;--heading-divider:5;--theme:ood9p0kg55vt1iq8tsdr2xnz4hx4dv18g1kl5unxk8;" data-marpit-pagination-total="38">
<h3 id="dbcontext-delete-operations">DbContext: Delete Operations</h3> <h3 id="dbcontext-delete-operations">DbContext: Delete Operations</h3>
<pre is="marp-pre" data-auto-scaling="downscale-only"><code class="language-csharp"><span class="hljs-keyword">public</span> <span class="hljs-keyword">class</span> <span class="hljs-title">ContactRepository</span> : <span class="hljs-title">IContactRepository</span> <pre is="marp-pre" data-auto-scaling="downscale-only"><code class="language-csharp"><span class="hljs-keyword">public</span> <span class="hljs-keyword">class</span> <span class="hljs-title">ContactRepository</span> : <span class="hljs-title">IContactRepository</span>
{ {
@ -378,7 +377,7 @@ services.AddControllers().AddNewtonsoftJson();
} }
</code></pre> </code></pre>
</section> </section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="25" data-marpit-fragments="2" data-paginate="true" data-class="exercise invert" data-heading-divider="5" data-theme="qxwzalhzytjx5wnlf6losqvbl44tf0bt7if1oe7ch9" lang="en-US" class="exercise invert" data-marpit-pagination="25" style="--paginate:true;--class:exercise invert;--heading-divider:5;--theme:qxwzalhzytjx5wnlf6losqvbl44tf0bt7if1oe7ch9;" data-marpit-pagination-total="38"> </foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="25" data-marpit-fragments="2" data-paginate="true" data-class="exercise invert" data-heading-divider="5" data-theme="ood9p0kg55vt1iq8tsdr2xnz4hx4dv18g1kl5unxk8" lang="en-US" class="exercise invert" data-marpit-pagination="25" style="--paginate:true;--class:exercise invert;--heading-divider:5;--theme:ood9p0kg55vt1iq8tsdr2xnz4hx4dv18g1kl5unxk8;" data-marpit-pagination-total="38">
<h3 id="exercise-2-crud-on-the-db">Exercise 2: CRUD on the DB</h3> <h3 id="exercise-2-crud-on-the-db">Exercise 2: CRUD on the DB</h3>
<p>Continue working on CourseAPI.</p> <p>Continue working on CourseAPI.</p>
@ -387,7 +386,7 @@ services.AddControllers().AddNewtonsoftJson();
<li data-marpit-fragment="2">Test with Postman. Keep refreshing the DB in pgAdmin or creating queries with psql to make sure the requests work as intended</li> <li data-marpit-fragment="2">Test with Postman. Keep refreshing the DB in pgAdmin or creating queries with psql to make sure the requests work as intended</li>
</ol> </ol>
</section> </section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="26" data-marpit-fragments="4" data-paginate="true" data-class="invert" data-heading-divider="5" data-theme="qxwzalhzytjx5wnlf6losqvbl44tf0bt7if1oe7ch9" lang="en-US" class="invert" data-marpit-pagination="26" style="--paginate:true;--class:invert;--heading-divider:5;--theme:qxwzalhzytjx5wnlf6losqvbl44tf0bt7if1oe7ch9;" data-marpit-pagination-total="38"> </foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="26" data-marpit-fragments="4" data-paginate="true" data-class="invert" data-heading-divider="5" data-theme="ood9p0kg55vt1iq8tsdr2xnz4hx4dv18g1kl5unxk8" lang="en-US" class="invert" data-marpit-pagination="26" style="--paginate:true;--class:invert;--heading-divider:5;--theme:ood9p0kg55vt1iq8tsdr2xnz4hx4dv18g1kl5unxk8;" data-marpit-pagination-total="38">
<h3 id="summing-things-up">Summing Things Up</h3> <h3 id="summing-things-up">Summing Things Up</h3>
<ul> <ul>
<li data-marpit-fragment="1">Now the API has been hooked up to a PostgreSQL database</li> <li data-marpit-fragment="1">Now the API has been hooked up to a PostgreSQL database</li>
@ -396,7 +395,7 @@ services.AddControllers().AddNewtonsoftJson();
<li data-marpit-fragment="4">Controllers accepting HTTP requests have access to the repository</li> <li data-marpit-fragment="4">Controllers accepting HTTP requests have access to the repository</li>
</ul> </ul>
</section> </section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="27" data-marpit-fragments="5" data-paginate="true" data-class="invert" data-heading-divider="5" data-theme="qxwzalhzytjx5wnlf6losqvbl44tf0bt7if1oe7ch9" lang="en-US" class="invert" data-marpit-pagination="27" style="--paginate:true;--class:invert;--heading-divider:5;--theme:qxwzalhzytjx5wnlf6losqvbl44tf0bt7if1oe7ch9;" data-marpit-pagination-total="38"> </foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="27" data-marpit-fragments="5" data-paginate="true" data-class="invert" data-heading-divider="5" data-theme="ood9p0kg55vt1iq8tsdr2xnz4hx4dv18g1kl5unxk8" lang="en-US" class="invert" data-marpit-pagination="27" style="--paginate:true;--class:invert;--heading-divider:5;--theme:ood9p0kg55vt1iq8tsdr2xnz4hx4dv18g1kl5unxk8;" data-marpit-pagination-total="38">
<h3 id="efcore-code-first-checklist">EFCore Code First Checklist</h3> <h3 id="efcore-code-first-checklist">EFCore Code First Checklist</h3>
<ol> <ol>
<li data-marpit-fragment="1">Install required packages</li> <li data-marpit-fragment="1">Install required packages</li>
@ -406,7 +405,7 @@ services.AddControllers().AddNewtonsoftJson();
<li data-marpit-fragment="5">Add CRUD operations to the database repository</li> <li data-marpit-fragment="5">Add CRUD operations to the database repository</li>
</ol> </ol>
</section> </section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="28" data-marpit-fragments="4" data-paginate="true" data-class="invert" data-heading-divider="5" data-theme="qxwzalhzytjx5wnlf6losqvbl44tf0bt7if1oe7ch9" lang="en-US" class="invert" data-marpit-pagination="28" style="--paginate:true;--class:invert;--heading-divider:5;--theme:qxwzalhzytjx5wnlf6losqvbl44tf0bt7if1oe7ch9;" data-marpit-pagination-total="38"> </foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="28" data-marpit-fragments="4" data-paginate="true" data-class="invert" data-heading-divider="5" data-theme="ood9p0kg55vt1iq8tsdr2xnz4hx4dv18g1kl5unxk8" lang="en-US" class="invert" data-marpit-pagination="28" style="--paginate:true;--class:invert;--heading-divider:5;--theme:ood9p0kg55vt1iq8tsdr2xnz4hx4dv18g1kl5unxk8;" data-marpit-pagination-total="38">
<h3 id="modifying-the-relations">Modifying the Relations</h3> <h3 id="modifying-the-relations">Modifying the Relations</h3>
<ul> <ul>
<li data-marpit-fragment="1">Let's change the structure of our Contacts API by adding a new class <code>Account</code> <li data-marpit-fragment="1">Let's change the structure of our Contacts API by adding a new class <code>Account</code>
@ -418,7 +417,7 @@ services.AddControllers().AddNewtonsoftJson();
<li data-marpit-fragment="4">Emails will be removed from the <code>Contacts</code> table</li> <li data-marpit-fragment="4">Emails will be removed from the <code>Contacts</code> table</li>
</ul> </ul>
</section> </section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="29" data-paginate="true" data-class="invert" data-heading-divider="5" data-theme="qxwzalhzytjx5wnlf6losqvbl44tf0bt7if1oe7ch9" lang="en-US" class="invert" data-marpit-pagination="29" style="--paginate:true;--class:invert;--heading-divider:5;--theme:qxwzalhzytjx5wnlf6losqvbl44tf0bt7if1oe7ch9;" data-marpit-pagination-total="38"> </foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="29" data-paginate="true" data-class="invert" data-heading-divider="5" data-theme="ood9p0kg55vt1iq8tsdr2xnz4hx4dv18g1kl5unxk8" lang="en-US" class="invert" data-marpit-pagination="29" style="--paginate:true;--class:invert;--heading-divider:5;--theme:ood9p0kg55vt1iq8tsdr2xnz4hx4dv18g1kl5unxk8;" data-marpit-pagination-total="38">
<pre is="marp-pre" data-auto-scaling="downscale-only"><code class="language-csharp"><span class="hljs-comment">// Models/Contact.cs</span> <pre is="marp-pre" data-auto-scaling="downscale-only"><code class="language-csharp"><span class="hljs-comment">// Models/Contact.cs</span>
<span class="hljs-keyword">public</span> <span class="hljs-keyword">class</span> <span class="hljs-title">Contact</span> <span class="hljs-keyword">public</span> <span class="hljs-keyword">class</span> <span class="hljs-title">Contact</span>
{ {
@ -438,13 +437,13 @@ services.AddControllers().AddNewtonsoftJson();
} }
</code></pre> </code></pre>
</section> </section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="30" data-marpit-fragments="1" data-paginate="true" data-class="invert" data-heading-divider="5" data-theme="qxwzalhzytjx5wnlf6losqvbl44tf0bt7if1oe7ch9" lang="en-US" class="invert" data-marpit-pagination="30" style="--paginate:true;--class:invert;--heading-divider:5;--theme:qxwzalhzytjx5wnlf6losqvbl44tf0bt7if1oe7ch9;" data-marpit-pagination-total="38"> </foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="30" data-marpit-fragments="1" data-paginate="true" data-class="invert" data-heading-divider="5" data-theme="ood9p0kg55vt1iq8tsdr2xnz4hx4dv18g1kl5unxk8" lang="en-US" class="invert" data-marpit-pagination="30" style="--paginate:true;--class:invert;--heading-divider:5;--theme:ood9p0kg55vt1iq8tsdr2xnz4hx4dv18g1kl5unxk8;" data-marpit-pagination-total="38">
<ul> <ul>
<li data-marpit-fragment="1">Adding a migration at this point will result in a warning:<br /> <li data-marpit-fragment="1">Adding a migration at this point will result in a warning:<br />
<img src="imgs/7-databases-with-entity-framework_14.png" alt="" style="width:1000px;" /></li> <img src="imgs/7-databases-with-entity-framework_14.png" alt="" style="width:1000px;" /></li>
</ul> </ul>
</section> </section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="31" data-marpit-fragments="5" data-paginate="true" data-class="invert" data-heading-divider="5" data-theme="qxwzalhzytjx5wnlf6losqvbl44tf0bt7if1oe7ch9" lang="en-US" class="invert" data-marpit-pagination="31" style="--paginate:true;--class:invert;--heading-divider:5;--theme:qxwzalhzytjx5wnlf6losqvbl44tf0bt7if1oe7ch9;" data-marpit-pagination-total="38"> </foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="31" data-marpit-fragments="5" data-paginate="true" data-class="invert" data-heading-divider="5" data-theme="ood9p0kg55vt1iq8tsdr2xnz4hx4dv18g1kl5unxk8" lang="en-US" class="invert" data-marpit-pagination="31" style="--paginate:true;--class:invert;--heading-divider:5;--theme:ood9p0kg55vt1iq8tsdr2xnz4hx4dv18g1kl5unxk8;" data-marpit-pagination-total="38">
<div class='columns32' markdown='1'> <div class='columns32' markdown='1'>
<div markdown='1'> <div markdown='1'>
<ul> <ul>
@ -466,7 +465,7 @@ services.AddControllers().AddNewtonsoftJson();
</div> </div>
</div> </div>
</section> </section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="32" data-marpit-fragments="4" data-paginate="true" data-class="exercise invert" data-heading-divider="5" data-theme="qxwzalhzytjx5wnlf6losqvbl44tf0bt7if1oe7ch9" lang="en-US" class="exercise invert" data-marpit-pagination="32" style="--paginate:true;--class:exercise invert;--heading-divider:5;--theme:qxwzalhzytjx5wnlf6losqvbl44tf0bt7if1oe7ch9;" data-marpit-pagination-total="38"> </foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="32" data-marpit-fragments="4" data-paginate="true" data-class="exercise invert" data-heading-divider="5" data-theme="ood9p0kg55vt1iq8tsdr2xnz4hx4dv18g1kl5unxk8" lang="en-US" class="exercise invert" data-marpit-pagination="32" style="--paginate:true;--class:exercise invert;--heading-divider:5;--theme:ood9p0kg55vt1iq8tsdr2xnz4hx4dv18g1kl5unxk8;" data-marpit-pagination-total="38">
<h3 id="exercise-3-adding-migrations">Exercise 3: Adding Migrations</h3> <h3 id="exercise-3-adding-migrations">Exercise 3: Adding Migrations</h3>
<p>Continue working on CourseAPI.</p> <p>Continue working on CourseAPI.</p>
@ -477,10 +476,10 @@ services.AddControllers().AddNewtonsoftJson();
<li data-marpit-fragment="4">Update the database. Check that the changes show up in the database with pgAdmin</li> <li data-marpit-fragment="4">Update the database. Check that the changes show up in the database with pgAdmin</li>
</ol> </ol>
</section> </section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="33" data-paginate="true" data-class="invert" data-heading-divider="5" data-theme="qxwzalhzytjx5wnlf6losqvbl44tf0bt7if1oe7ch9" lang="en-US" class="invert" data-marpit-pagination="33" style="--paginate:true;--class:invert;--heading-divider:5;--theme:qxwzalhzytjx5wnlf6losqvbl44tf0bt7if1oe7ch9;" data-marpit-pagination-total="38"> </foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="33" data-paginate="true" data-class="invert" data-heading-divider="5" data-theme="ood9p0kg55vt1iq8tsdr2xnz4hx4dv18g1kl5unxk8" lang="en-US" class="invert" data-marpit-pagination="33" style="--paginate:true;--class:invert;--heading-divider:5;--theme:ood9p0kg55vt1iq8tsdr2xnz4hx4dv18g1kl5unxk8;" data-marpit-pagination-total="38">
<h2 id="database-first-approach">Database First approach</h2> <h2 id="database-first-approach">Database First approach</h2>
</section> </section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="34" data-marpit-fragments="7" data-paginate="true" data-class="invert" data-heading-divider="5" data-theme="qxwzalhzytjx5wnlf6losqvbl44tf0bt7if1oe7ch9" lang="en-US" class="invert" data-marpit-pagination="34" style="--paginate:true;--class:invert;--heading-divider:5;--theme:qxwzalhzytjx5wnlf6losqvbl44tf0bt7if1oe7ch9;" data-marpit-pagination-total="38"> </foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="34" data-marpit-fragments="7" data-paginate="true" data-class="invert" data-heading-divider="5" data-theme="ood9p0kg55vt1iq8tsdr2xnz4hx4dv18g1kl5unxk8" lang="en-US" class="invert" data-marpit-pagination="34" style="--paginate:true;--class:invert;--heading-divider:5;--theme:ood9p0kg55vt1iq8tsdr2xnz4hx4dv18g1kl5unxk8;" data-marpit-pagination-total="38">
<h3 id="what-is-the-database-first-approach">What is the Database First approach?</h3> <h3 id="what-is-the-database-first-approach">What is the Database First approach?</h3>
<ul> <ul>
<li data-marpit-fragment="1">This is the other approach for creating a connection between the database and the application</li> <li data-marpit-fragment="1">This is the other approach for creating a connection between the database and the application</li>
@ -495,7 +494,7 @@ services.AddControllers().AddNewtonsoftJson();
</li> </li>
</ul> </ul>
</section> </section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="35" data-marpit-fragments="4" data-paginate="true" data-class="invert" data-heading-divider="5" data-theme="qxwzalhzytjx5wnlf6losqvbl44tf0bt7if1oe7ch9" lang="en-US" class="invert" data-marpit-pagination="35" style="--paginate:true;--class:invert;--heading-divider:5;--theme:qxwzalhzytjx5wnlf6losqvbl44tf0bt7if1oe7ch9;" data-marpit-pagination-total="38"> </foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="35" data-marpit-fragments="4" data-paginate="true" data-class="invert" data-heading-divider="5" data-theme="ood9p0kg55vt1iq8tsdr2xnz4hx4dv18g1kl5unxk8" lang="en-US" class="invert" data-marpit-pagination="35" style="--paginate:true;--class:invert;--heading-divider:5;--theme:ood9p0kg55vt1iq8tsdr2xnz4hx4dv18g1kl5unxk8;" data-marpit-pagination-total="38">
<h3 id="scaffolding">Scaffolding</h3> <h3 id="scaffolding">Scaffolding</h3>
<ul> <ul>
<li data-marpit-fragment="1">Use the Package Manager Console to &quot;reverse engineer&quot; the code for an existing database <li data-marpit-fragment="1">Use the Package Manager Console to &quot;reverse engineer&quot; the code for an existing database
@ -509,7 +508,7 @@ services.AddControllers().AddNewtonsoftJson();
<li data-marpit-fragment="4">Using the connection string corresponding to your database, this will create all the classes for the entities in the DB as well as the context class</li> <li data-marpit-fragment="4">Using the connection string corresponding to your database, this will create all the classes for the entities in the DB as well as the context class</li>
</ul> </ul>
</section> </section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="36" data-marpit-fragments="2" data-paginate="true" data-class="exercise invert" data-heading-divider="5" data-theme="qxwzalhzytjx5wnlf6losqvbl44tf0bt7if1oe7ch9" lang="en-US" class="exercise invert" data-marpit-pagination="36" style="--paginate:true;--class:exercise invert;--heading-divider:5;--theme:qxwzalhzytjx5wnlf6losqvbl44tf0bt7if1oe7ch9;" data-marpit-pagination-total="38"> </foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="36" data-marpit-fragments="2" data-paginate="true" data-class="exercise invert" data-heading-divider="5" data-theme="ood9p0kg55vt1iq8tsdr2xnz4hx4dv18g1kl5unxk8" lang="en-US" class="exercise invert" data-marpit-pagination="36" style="--paginate:true;--class:exercise invert;--heading-divider:5;--theme:ood9p0kg55vt1iq8tsdr2xnz4hx4dv18g1kl5unxk8;" data-marpit-pagination-total="38">
<h3 id="exercise-4-database-first">Exercise 4: Database First</h3> <h3 id="exercise-4-database-first">Exercise 4: Database First</h3>
<p>Create a new ASP.NET Core web app using the API template.</p> <p>Create a new ASP.NET Core web app using the API template.</p>
@ -520,13 +519,13 @@ b) by copying the <code>&lt;PackageReference&gt;</code> lines from the <code>.cs
<li data-marpit-fragment="2">Scaffold the <code>sqlpractice</code> database created in <a href="sql-databases#exercise-1-preparing-the-database">SQL Databases Exercise 1</a> to the project by using the Database First approach. If you have not yet created the database in PostgreSQL, it can be found <a href="code-examples/example-query.sql">here</a></li> <li data-marpit-fragment="2">Scaffold the <code>sqlpractice</code> database created in <a href="sql-databases#exercise-1-preparing-the-database">SQL Databases Exercise 1</a> to the project by using the Database First approach. If you have not yet created the database in PostgreSQL, it can be found <a href="code-examples/example-query.sql">here</a></li>
</ol> </ol>
</section> </section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="37" data-marpit-fragments="1" data-paginate="true" data-class="invert" data-heading-divider="5" data-theme="qxwzalhzytjx5wnlf6losqvbl44tf0bt7if1oe7ch9" lang="en-US" class="invert" data-marpit-pagination="37" style="--paginate:true;--class:invert;--heading-divider:5;--theme:qxwzalhzytjx5wnlf6losqvbl44tf0bt7if1oe7ch9;" data-marpit-pagination-total="38"> </foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="37" data-marpit-fragments="1" data-paginate="true" data-class="invert" data-heading-divider="5" data-theme="ood9p0kg55vt1iq8tsdr2xnz4hx4dv18g1kl5unxk8" lang="en-US" class="invert" data-marpit-pagination="37" style="--paginate:true;--class:invert;--heading-divider:5;--theme:ood9p0kg55vt1iq8tsdr2xnz4hx4dv18g1kl5unxk8;" data-marpit-pagination-total="38">
<h3 id="reading-authentication-with-roles">Reading: Authentication with roles</h3> <h3 id="reading-authentication-with-roles">Reading: Authentication with roles</h3>
<ul> <ul>
<li data-marpit-fragment="1"><a href="https://www.c-sharpcorner.com/article/jwt-token-creation-authentication-and-authorization-in-asp-net-core-6-0-with-po/">Here's</a> an example how to do a role-based authentication by using JWT tokens</li> <li data-marpit-fragment="1"><a href="https://www.c-sharpcorner.com/article/jwt-token-creation-authentication-and-authorization-in-asp-net-core-6-0-with-po/">Here's</a> an example how to do a role-based authentication by using JWT tokens</li>
</ul> </ul>
</section> </section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="38" data-marpit-fragments="2" data-paginate="true" data-class="exercise invert" data-heading-divider="5" data-theme="qxwzalhzytjx5wnlf6losqvbl44tf0bt7if1oe7ch9" lang="en-US" class="exercise invert" data-marpit-pagination="38" style="--paginate:true;--class:exercise invert;--heading-divider:5;--theme:qxwzalhzytjx5wnlf6losqvbl44tf0bt7if1oe7ch9;" data-marpit-pagination-total="38"> </foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="38" data-marpit-fragments="2" data-paginate="true" data-class="exercise invert" data-heading-divider="5" data-theme="ood9p0kg55vt1iq8tsdr2xnz4hx4dv18g1kl5unxk8" lang="en-US" class="exercise invert" data-marpit-pagination="38" style="--paginate:true;--class:exercise invert;--heading-divider:5;--theme:ood9p0kg55vt1iq8tsdr2xnz4hx4dv18g1kl5unxk8;" data-marpit-pagination-total="38">
<h3 id="exercise-5-extra-connection">Exercise 5 (Extra): Connection</h3> <h3 id="exercise-5-extra-connection">Exercise 5 (Extra): Connection</h3>
<p>Continuing the previous exercise,</p> <p>Continuing the previous exercise,</p>

@ -16,10 +16,8 @@ title: 5. Databases with Entity Framework
- [Entity Framework (EF)](#entity-framework-ef) - [Entity Framework (EF)](#entity-framework-ef)
- [Code First approach](#code-first-approach) - [Code First approach](#code-first-approach)
- [Migrations](#migrations) - [Migrations](#migrations)
- [Migrations](#migrations)
- [Database First approach](#database-first-approach) - [Database First approach](#database-first-approach)
## Entity Framework (EF) ## Entity Framework (EF)
* This lecture will assume you have a basic understanding of SQL databases * This lecture will assume you have a basic understanding of SQL databases

@ -9,4 +9,4 @@
| 5 | [Model Validation & API Design](5-model-validation-and-designing-apis.md) | [Download slides](5-model-validation-and-designing-apis-slides.html?raw=1) | | 5 | [Model Validation & API Design](5-model-validation-and-designing-apis.md) | [Download slides](5-model-validation-and-designing-apis-slides.html?raw=1) |
| 6 | [Databases with Entity Framework](6-databases-with-entity-framework.md) | [Download slides](6-databases-with-entity-framework-slides.html?raw=1) | | 6 | [Databases with Entity Framework](6-databases-with-entity-framework.md) | [Download slides](6-databases-with-entity-framework-slides.html?raw=1) |
| 7 | [Authentication and Authorization](7-authentication-and-authorization.md) | [Download slides](7-authentication-and-authorization-slides.html?raw=1) | | 7 | [Authentication and Authorization](7-authentication-and-authorization.md) | [Download slides](7-authentication-and-authorization-slides.html?raw=1) |
| 8 | [Testing](8-testing.md) | [Download slides](8-testing-slides.html?raw=1) | | 8 | [Testing](8-testing.md) | [Download slides](8-testing-slides.html?raw=1) |
Loading…
Cancel
Save