Modern Data Access with Entity Framework Core: Database Programming Techniques for . NET, . NET Core, UWP, and Xamarin with C# 1st Edition Holger Schwichtenberg all chapter instant download
Modern Data Access with Entity Framework Core: Database Programming Techniques for . NET, . NET Core, UWP, and Xamarin with C# 1st Edition Holger Schwichtenberg all chapter instant download
com
OR CLICK BUTTON
DOWNLOAD NOW
https://textbookfull.com/product/biota-grow-2c-gather-2c-cook-loucas/
textboxfull.com
https://textbookfull.com/product/pro-c-7-with-net-and-net-core-andrew-
troelsen/
textboxfull.com
https://textbookfull.com/product/beginning-visual-studio-for-mac-
build-cross-platform-apps-with-xamarin-and-net-core-alessandro-del-
sole/
textboxfull.com
https://textbookfull.com/product/pro-c-8-with-net-core-3-foundational-
principles-and-practices-in-programming-ninth-edition-andrew-troelsen/
textboxfull.com
Modern Data
Access with Entity
Framework Core
Database Programming Techniques
for .NET, .NET Core, UWP, and Xamarin
with C#
—
Holger Schwichtenberg
Modern Data Access with
Entity Framework Core
Database Programming Techniques
for .NET, .NET Core, UWP, and
Xamarin with C#
Holger Schwichtenberg
Modern Data Access with Entity Framework Core
Holger Schwichtenberg
Essen, Germany
Introduction������������������������������������������������������������������������������������������������������������xix
v
Table of Contents
vi
Table of Contents
vii
Table of Contents
Add-Migration��������������������������������������������������������������������������������������������������������������������������� 115
Update-Database���������������������������������������������������������������������������������������������������������������������� 120
Script-Migration������������������������������������������������������������������������������������������������������������������������ 121
Further Migration Steps������������������������������������������������������������������������������������������������������������ 122
Migration Scenarios������������������������������������������������������������������������������������������������������������������ 122
More Options����������������������������������������������������������������������������������������������������������������������������� 125
Problems with Schema Migration in Connection with TFS������������������������������������������������������� 127
Schema Migrations at Runtime������������������������������������������������������������������������������������������������� 127
viii
Table of Contents
ix
Table of Contents
x
Table of Contents
Chapter 15: Reading and Modifying Data with SQL, Stored Procedures,
and Table-Valued Functions������������������������������������������������������������� 305
Writing Queries with FromSql()������������������������������������������������������������������������������������������������� 306
Using LINQ and SQL Together��������������������������������������������������������������������������������������������������� 308
Using Stored Procedures and Table-Valued Functions������������������������������������������������������������� 311
Using Nonentity Classes as Result Sets������������������������������������������������������������������������������������ 313
Using SQL DML Commands Without Result Sets���������������������������������������������������������������������� 315
xi
Table of Contents
xii
Table of Contents
xiii
Table of Contents
xiv
Table of Contents
xv
Table of Contents
Index��������������������������������������������������������������������������������������������������������������������� 635
xvi
About the Author
Holger Schwichtenberg is a .NET MVP with more than
20 years of experience as a developer and trainer. He is
currently a technical lead with the German company
IT-Visions, where he consults and trains at companies
throughout Europe. He also serves as a software architect
for 5Minds IT-Solutions. Holger is a huge fan of Entity
Framework (EF) and Entity Framework Core and regularly
speaks about both. He has used EF in projects of all sizes,
most recently on a big data project containing billions of
records. He is a prolific writer, having published more than
65 books and 1,000 technical articles in well-known IT
professional and developer journals, including MSDN. He has presented at events such
as TechEd Europe, Microsoft IT Forum, Advanced Developer Conference, Microsoft
Launch, MSDN Technical Summit, and others. Holger has a PhD in business informatics.
His company web sites are www.IT-Visions.de and www.5minds.de, and he regularly
blogs at dotnet-doktor.de. His office can be reached at [email protected].
xvii
Introduction
I have always been a big fan of object-relational mapping (ORM); in fact, I developed
my own OR mapper for my software development projects in the early days of .NET. I
switched to the ADO.NET Entity Framework when Microsoft introduced it in .NET 3.5
Service Pack 1. Nowadays, I prefer its successor, Entity Framework Core. Interestingly,
some of my projects are still running the classic Entity Framework. As Microsoft
continues to do incremental releases of Entity Framework Core, many of the challenges
and gripes developers had with earlier versions have gone away, so my plan is to switch
the management of all my projects to Entity Framework Core.
The book you hold in your hands came from an idea I had to cover all the important
database access scenarios. I hadn’t found much collective information in one place
and felt that a compendium could be of great value to others. In this book, you will
be introduced to database access concepts, get hands-on experience installing Entity
Framework Core, and learn about reverse engineering and forward engineering for
existing or legacy databases. I’ll delve into topics such as schema migrations, data
reading, and data modification with LINQ, Dynamic LINQ, APIs, SQL, stored procedures
and table-valued functions, object relationships, and asynchronous programming.
I’ll also talk about third-party products such as LINQPad, Entity Developer, Entity
Framework Profiler, Entity Framework Plus, and AutoMapper.
I’ll discuss how to apply Entity Framework Core through case studies using Universal
Windows Platform (UWP) apps, Xamarin, and ASP.NET Core. Of course, no book would
be complete without sharing a healthy dose of hard-earned tips and tricks from my
experience with Entity Framework and Entity Framework Core over the years.
xix
Introduction
Note You’ll see other case studies used in some chapters, such as the task
management app MiracleList.
The World Wide Wings use case deals with the following entities:
• Employees of the airline, who have supervisors who are also employees.
xx
Introduction
The World Wide Wings use case has two data models, explained here:
• The slightly simpler model version 1 (see Figures 2 and 3) is the result
of classic relational database design with normalization. The object
model is created by reverse engineering.
xxi
Introduction
Figure 3. Object model of the World Wide Wings data model in the simpler version 1
In model version 1 there is a separate table for people (called Person), staff,
pilots, employee, and passengers. This separation corresponds to the classes in the
object model.
xxii
Introduction
Figure 4. World Wide Wings data model in the more complex version 2
xxiii
Introduction
Figure 5. Object model for the World Wide Wings data model in the more complex
version 2
Note The object models that were created in this book for the data models do
not represent an ideal object model because Entity Framework Core does not
support some mapping capabilities, such as N:M mapping, yet.
The object model for the data schema of World Wide Wings version 6.1 (Figure 3)
was automatically generated by the Entity Framework Core from the database
(through reverse engineering); I deliberately did not change it, even if some of the
generated names are ugly.
In model version 2, there are only the Passenger and Employee tables for these four
entities. Entity Framework Core is currently somewhat limited and does not support
table per type mapping (a separate table for each class). Therefore, the table Passenger
also includes all the characteristics of Person. In addition to the Person properties, the
xxiv
Introduction
Employee table includes the properties of the Employee and Pilot entities. In the table, a
Discriminator column distinguishes between records that are an employee and those
that are a pilot. Entity Framework Core mixes the concepts of table by concrete type
(TPC) and table by hierarchy (TPH). The developer has no definite influence on the
inheritance mapping in Entity Framework Core 1.x/2.0. The classic Entity Framework
offers more options here.
The following are the extra dependencies in model version 2:
• Each Person and therefore each Pilot and Passenger must own a
Persondetail object.
In this book, both data models are used, partly in modified form, to show certain
scenarios (for example, database schema migrations).
xxv
Introduction
Listing 1. Class CUI with Subroutines for Screen Output to the Console
using System;
using System.Runtime.InteropServices;
using System.Web;
using ITVisions.UI;
using System.Diagnostics;
namespace ITVisions
{
/// <summary>
/// Helper utilities for Console UIs
/// (C) Dr. Holger Schwichtenberg 2002-2018
/// </summary>
public static class CUI
{
public static bool IsDebug = false;
public static bool IsVerbose = false;
xxvi
Introduction
}
public static void Headline(string s)
{
Print(s, ConsoleColor.Yellow);
}
public static void HeaderFooter(string s)
{
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine(s);
Console.ForegroundColor = ConsoleColor.Gray;
}
xxvii
Introduction
xxviii
Introduction
/// <summary>
/// Print with Thread-ID
/// </summary>
public static void PrintWithThreadID(string s, ConsoleColor c =
ConsoleColor.White)
{
var ausgabe = String.Format("Thread #{0:00} {1:}: {2}", System.Threading.
Thread.CurrentThread.ManagedThreadId, DateTime.Now.ToLongTimeString(), s);
CUI.Print(ausgabe, c);
}
/// <summary>
/// Print with time
/// </summary>
public static void PrintWithTime(object s, ConsoleColor c = ConsoleColor.
White)
xxix
Introduction
{
CUI.Print(DateTime.Now.Second + "." + DateTime.Now.Millisecond + ":" + s);
}
#endregion
/// <summary>
/// Output to console, trace and file
/// </summary>
/// <param name="s"></param>
[DebuggerStepThrough()]
xxx
Another Random Scribd Document
with Unrelated Content
“Is some one ill?” she asked again.
“No; some one—some one is very well!” I managed to reply,
lifting my eyes again to her wan face. The spectacle of its drawn
lines and pallor all at once assailed my wearied and overtaxed
nerves with crushing weight. I felt myself beginning to whimper, and
rushing tears scalded my eyes. Something inside my breast seemed
to be dragging me down through the stoop.
I have now only the recollection of Miss Stratford’s kneeling by
my side, with a supporting arm around me, and of her thus unrolling
and reading the proof-paper I had in my hand. We were in the hall
now, instead of on the stoop, and there was a long silence. Then she
put her head on my shoulder and wept. I could hear and feel her
sobs as if they were my own.
“I—I didn’t think you’d cry—that you’d be so sorry,” I heard
myself saying, at last, in despondent self-defence.
Miss Stratford lifted her head and, still kneeling as she was, put
a finger under my chin to make me look her in her face. Lo! the eyes
were laughing through their tears; the whole countenance was
radiant once more with the light of happy youth and with that other
glory which youth knows only once.
“Why, Andrew, boy,” she said, trembling, smiling, sobbing,
beaming all at once, “didn’t you know that people cry for very joy
sometimes?”
And as I shook my head she bent down and kissed me.
BIBLIOGRAPHICAL NOTE
[Since any list approaching a complete bibliography would
be unduly long, these suggestions are merely for the
convenience of those who, without special research, wish to
read further and compare. They remain after rejection of many
essays that seem hardly to advance the discussion.]
anecdote 55
(a) simple anecdote 34
I, all but nov. 4; III, nov. 4; V, nov. 4; VI,
entire; VIII, all but nov. 7 & 8; IX, nov.
1 & 7–10.
(b) anecdote more artistically elaborated 21
III, nov. 1, 2, 3, 5, 6; V, nov. 10; VII,
entire; VIII, nov. 7; IX, nov. 2–5.
scenario or summary romance 40
II, nov. 3–10; III, nov. 7–10; IV, entire;
V, all but nov. 4 & 10; X, entire.
approaching short story 3
I, nov. 4; II, nov. 1; VIII, nov. 8.
short story 2
II, nov. 2; IX, nov. 6.
100
31
E. Gilbert, Le roman en France pendant le xixe siècle, page 65;
A. France, La vie littéraire, Ire série, page 47.
32
Brander Matthews, The Philosophy of the Short-Story, page
65.
33
Colomba has one hundred and fifty pages.
34
See an essay on The Literary Influence of Sterne in France,
Publications of the Modern Language Association of America,
volume xvii, pages 221–236.
35
It would be interesting, for instance, to determine whether
Mérimée learned anything in form from Poushkin.
36
Vide the excellent discourse of G. C. Verplanck, Esq., before
the New York Historical Society.
37
Not in the first edition.
38
In New Hampshire.
39
In the original publication the name is Patience.
40
[“In place of this clause the first edition has: “Her figure, her
air, her features,—all, in their very minutest development were
those—were identically (I can use no other sufficient term)
were identically those of the Roderick Usher who sat beside
me. A feeling of stupor,” etc.]
41
Watson, Dr. Percival, Spallanzani, and especially the Bishop of
Llandaff. See Chemical Essays, vol. v.
42
The season of peach-blossoms was the only season of
marriage in ancient China.
43
The most common decorations of rooms, halls, and temples, in
China, are ornamental scrolls or labels of colored paper or
wood, painted and gilded, and hung over doors or windows,
and inscribed with a line or couplet conveying some allusion to
the circumstances of the inhabitant, or some pious or
philosophical axiom. For instance, a poetical one recorded by
Dr. Morrison:—
“From the pine forest the azure dragon ascends to the milky way,”—
Bacon, Delia, 11
Balzac, Honoré de, 32–33;
El verdugo, Les proscrits, La messe de l’athée, Z. Marcas, 32;
form in, 32–33
Bandello, 29
Beckwith, Hiram W., 97
Bee-Tree, The (Kirkland), 195–210
Beers, Henry A., 2, 177
Ben Hadar (Paulding), 10
Berenice (Poe), 2, 3, 16, 18, 21, 22, 33
Blackwell, Robert, 97
Boccaccio, “The Decameron,” 26–28, 30
“Boston Book, The,” 61
Brunetière, Ferdinand, 26
Buckthorne and His Friends (Irving), 8
Bunner, Henry Cuyler, 289–301;
biographical and critical note, 289;
The Third Figure of the Cotillion, 289;
The Love Letters of Smith, 291–301
Burton’s “Gentleman’s Magazine,” 154
Edgeworth, Maria, 26
Emigrant’s Daughter, The, 5
End of the Passage, The (Kipling), 212
Enlèvement de la redoute, Le (Mérimée), 31
Esmeralda, The (Wallace), 11
Essay tendency in tales, 6, 7, 10, 14, 15, 18, 32
Ethan Brand (Hawthorne), 13
Eve of the Fourth, The (Frederic), 305–324
Exposition in tales (see Essay tendency)
Hale, Mrs., 5
Hall, James, 5, 9, 11, 12, 97–112;
biographical and critical note, 97;
“The Illinois Intelligencer,” “The Illinois Magazine,” “The
Western Monthly Magazine,” “Letters from the West,”
“Sketches of the West,” “Notes on the Western States,”
“The Wilderness and the War Path,” 97;
“The Western Souvenir,” 5, 97;
The Indian Hater, Pete Featherton, 5;
The Village Musician, 9;
The French Village, 5, 9, 12, 99–112
Harmonisation, 16, 23
“Harper’s Monthly Magazine,” 212, 213
Hart, Walter Morris, 325
Harte, Francis Bret, 4, 229–243;
biographical and critical note, 229;
“Condensed Novels,” 229;
The Luck of Roaring Camp, 229, 230;
Johnson’s Old Woman, Mrs. Skaggs’s Husbands, The Iliad of
Sandy Bar, Tennessee’s Partner, 230;
The Outcasts of Poker Flat, 231–243;
influence of Dickens, 230;
of Dumas, 230;
tendency to melodrama, 230;
local truth, 229;
symbolism, 230
Hawthorne, Nathaniel, 2, 5, 9, 10, 12–15, 16, 18, 23, 30, 31,
32, 59, 129–142, 230;
bent not toward short story, 12–15, 31;
allegory, symbolism, 14, 23, 230;
vocabulary, 16;
tendency toward description, 14;
toward essay, 14, 15, 18, 30;
expository introductions, 18;
unity compared with Poe’s, 23;
likeness to Nodier, 30;
“Twice-Told Tales,” 131;
The Gentle Boy, 12;
The Wives of the Dead, 12, 13;
Roger Malvin’s Burial, Alice Doane’s Appeal, Ethan Brand, 13;
The Scarlet Letter, 13, 14;
Sunday at Home, Sights from a Steeple, Main Street, The
Village Uncle, The Ambitious Guest, Fancy’s Show Box,
David Swan, The Snow Image, The Great Stone Face, 14;
The Marble Faun, 15;
The White Old Maid, 13, 131–142;
The Seven Vagabonds, 230
“Heptameron, The,” of the Queen of Navarre, 29
Hermit of the Prairies, The, 5
“Hermite de la Chaussée d’Antin, Le,” 6
Higginson, Thomas Wentworth, 59
Historical tales, 4, 5, 9, 10, 11
Hoax-story, 10, 34
Horla, Le (Maupassant), 212
Jacobs, Joseph, 25
James, Henry, 34
Jean François-les-bas-bleus (Nodier), 30
Johnson’s Old Woman (Harte), 230
Joseph Natterstrom (Austin), 1, 10
Jouy, M. de, 6
Jumping Frog, The (Mark Twain), 34
“Satyricon” (Petronius), 24
Scarlet Letter, The (Hawthorne), 13, 14
Scenario, or summary romance, 10, 13, 24, 26, 27
Schlegel, Poe’s application of, 22
Scott, Sir Walter, influence of, 11, 37
Sedgwick, Charlotte M., A Reminiscence of Federalism, Mary
Dyre, The Chivalric Sailor, 11
Sequence of incidents, 7, 8, 9, 10, 16, 20–23 (see Gradation)
Setting, 16 (see Local color)
Seven Vagabonds, The (Hawthorne), 230
“Short Sixes” (Bunner), 291
Short story, in antiquity, 24, 25;
in middle age, 25–29;
in France, 29–35;
in America, 1–23, 34, 35;
in England, 33, 34;
in other countries, 34;
popularity of, 3, 34;
distinct from tale and novel, 2, 6, 7, 8, 11, 12, 13, 21, 23–27,
29–31;
unity of, 7, 8, 11–13, 15–23;
intensity of, 12, 13, 32 (see Unity)
“Short-Story, The Philosophy of the” (Matthews), 11, 12, 31,
212, 325
Sights from a Steeple (Hawthorne), 14
Simple plots and complex, 13–15, 25, 26
Simplification of narrative mechanism, 7, 8, 11, 12, 13, 17–20,
23 (see Unity)
Singleness, 13, 15, 19, 31 (see Unity)
Situation, a single, in short story, 12, 26, 27, 28, 31
“Sketch Book, The” (Irving), 7, 8, 37
“Sketches of the West” (Hall), 97
Smarra (Nodier), 30
Snow Image, The (Hawthorne), 14
“Southern Literary Messenger, The,” 2, 33
“Spectator, The,” 6, 7, 9;
influence on Irving, 6, 7;
on the British novel, 6;
in France, 6;
on J. P. Kennedy, 9;
in Virginia, 9
Spectre Bridegroom, The (Irving), 7
Static narrative, and kinetic, 22
Sterne, Lawrence, influence on Gautier, 33
Stevenson, Robert Louis, 34
Stockton, Frank R., The Wreck of the Thomas Hyke, 34
Sunday at Home (Hawthorne), 14
Suspense, 10, 16, 20
“Swallow Barn” (Kennedy), 9
Symbolism, 10, 14, 23, 230
Yarn, 10, 34
Z. Marcas (Balzac), 32
PRINTED IN THE UNITED STATES OF AMERICA
Transcriber’s Notes
Punctuation, hyphenation, and spelling were made
consistent when a predominant preference was found in the
original book; otherwise they were not changed.
Simple typographical errors were corrected; unbalanced
quotation marks were remedied when the change was
obvious, and otherwise left unbalanced.
Footnotes, originally at the bottoms of the pages that
referenced them, have been collected, sequentially
renumbered, and placed at the end of the book.
The index was not checked for proper alphabetization or
correct page references.
*** END OF THE PROJECT GUTENBERG EBOOK AMERICAN SHORT
STORIES ***
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
textbookfull.com