magazine
THE MICROSOFT JOURNAL FOR DEVELOPERS
AUGUST 2016 VOL 31 NO 8
From Code to Customer:
Exploring Mobile DevOps
Kraig Brockschmidt .......................................................... 16
Applying DevOps to a
Software Development Project
Wouter de Kort, Willy Schaub and Mattias Sköld ................. 24
Commit to Git: Source Control
in Visual Studio 2015
Jonathan Waldman ..........................................................30
Write Apps with Visual Studio Code
and Entity Framework
Alessandro Del Sole .........................................................38
Real-World ASP.NET Core MVC Filters
Steve Smith .....................................................................54
COLUMNS
CUTTING EDGE
Beyond CRUD: Commands,
Events and Bus
Dino Esposito, page 6
DATA POINTS
EF Core Change-Tracking
Behavior: Unchanged,
Modied and Added
Julie Lerman, page 10
TEST RUN
Lightweight Random
Number Generation
James McCaffrey, page 64
THE WORKING
PROGRAMMER
How To Be MEAN:
Exploring ECMAScript
Ted Neward, page 70
DON’T GET ME STARTED
Sing a Song of Silicon
David Platt, page 80
Better Living
Through DevOps....16, 24, 30
0816msdn_C1_v1.indd 1 7/12/16 12:19 PM
msdn magazine
2
ID STATEMENT MSDN Magazine (ISSN 1528-4859) is
published monthly by 1105 Media, Inc., 9201 Oakdale
Avenue, Ste. 101, Chatsworth, CA 91311. Periodicals
postage paid at Chatsworth, CA 91311-9998, and at
additional mailing ofces. Annual subscription rates
payable in US funds are: U.S. $35.00, International
$60.00. Annual digital subscription rates payable in
U.S. funds are: U.S. $25.00, International $25.00. Single
copies/back issues: U.S. $10, all others $12. Send orders
with payment to: MSDN Magazine, P.O. Box 3167, Carol
Stream, IL 60132, email MSDNmag@1105service.com
or call (847) 763-9560. POSTMASTER: Send address
changes to MSDN Magazine, P.O. Box 2166, Skokie,
IL 60076. Canada Publications Mail Agreement No:
40612608. Return Undeliverable Canadian Addresses
to Circulation Dept. or XPO Returns: P.O. Box 201,
Richmond Hill, ON L4B 4R5, Canada.
Printed in the U.S.A. Reproductions in whole or part
prohibited except by written permission. Mail requests
to “Permissions Editor,” c/o MSDN Magazine, 4 Venture,
Suite 150, Irvine, CA 92618.
LEGAL DISCLAIMER The information in this magazine
has not undergone any formal testing by 1105 Media,
Inc. and is distributed without any warranty expressed
or implied. Implementation or use of any information
contained herein is the reader’s sole responsibility. While
the information has been reviewed for accuracy, there
is no guarantee that the same or similar results may be
achieved in all environments. Technical inaccuracies may
result from printing errors and/or new developments
in the industry.
CORPORATE ADDRESS 1105 Media, 9201 Oakdale Ave.
Ste 101, Chatsworth, CA 91311 www.1105media.com
MEDIA KITS Direct your Media Kit requests to Chief
Revenue Ofcer Dan LaBianca, 972-687-6702 (phone),
972-687-6799 (fax), dlabianca@1105media.com
REPRINTS For single article reprints (in minimum
quantities of 250-500), e-prints, plaques and posters
contact: PARS International Phone: 212-221-9595.
E-mail: 1105reprints@parsintl.com.
www.magreprints.com/QuickQuote.asp
LIST RENTAL This publication’s subscriber list, as well as
other lists from 1105 Media, Inc., is available for rental.
For more information, please contact our list manager,
Jane Long, Merit Direct. Phone: 913-685-1301;
E-mail: jlong@meritdirect.com;
Web: www.meritdirect.com/1105
Reaching the Staff
Staff may be reached via e-mail, telephone, fax, or mail.
A list of editors and contact information is also available
online at Redmondmag.com.
E-mail: To e-mail any member of the staff, please use the
following form: FirstinitialLastname@1105media.com
Irvine Ofce (weekdays, 9:00 a.m. – 5:00 p.m. PT)
Telephone 949-265-1520; Fax 949-265-1528
4 Venture, Suite 150, Irvine, CA 92618
Corporate Ofce (weekdays, 8:30 a.m. – 5:30 p.m. PT)
Telephone 818-814-5200; Fax 818-734-1522
9201 Oakdale Avenue, Suite 101, Chatsworth, CA 91311
The opinions expressed within the articles and other
contentsherein do not necessarily express those of
the publisher.
President
Henry Allain
Chief Revenue Ofcer
Dan LaBianca
Chief Marketing Ofcer
Carmel McDonagh
ART STAFF
Creative Director Jeffrey Langkau
Associate Creative Director Scott Rovin
Senior Art Director Deirdre Hoffman
Art Director Michele Singh
Assistant Art Director Dragutin Cvijanovic
Graphic Designer Erin Horlacher
Senior Graphic Designer Alan Tao
Senior Web Designer Martin Peace
PRODUCTION STAFF
Print Production Coordinator Lee Alexander
ADVERTISING AND SALES
Chief Revenue Ofcer Dan LaBianca
Regional Sales Manager Christopher Kourtoglou
Account Executive Caroline Stover
Advertising Sales Associate Tanya Egenolf
ONLINE/DIGITAL MEDIA
Vice President, Digital Strategy Becky Nagel
Senior Site Producer, News Kurt Mackie
Senior Site Producer Gladys Rama
Site Producer Chris Paoli
Site Producer, News David Ramel
Director, Site Administration Shane Lee
Site Administrator Biswarup Bhattacharjee
Front-End Developer Anya Smolinski
Junior Front-End Developer Casey Rysavy
Executive Producer, New Media Michael Domingo
Ofce Manager & Site Assoc. James Bowling
LEAD SERVICES
Vice President, Lead Services Michele Imgrund
Senior Director, Audience Development
& Data Procurement Annette Levee
Director, Audience Development
& Lead Generation Marketing Irene Fincher
Director, Client Services & Webinar
Production Tracy Cook
Director, Lead Generation Marketing Eric Yoshizuru
Director, Custom Assets & Client Services Mallory Bundy
Senior Program Manager, Client Services
& Webinar Production Chris Flack
Project Manager, Lead Generation Marketing
Mahal Ramos
Coordinator, Lead Generation Marketing
Obum Ukabam
MARKETING
Chief Marketing Ofcer Carmel McDonagh
Vice President, Marketing Emily Jacobs
Senior Manager, Marketing Christopher Morales
Marketing Coordinator Alicia Chew
Marketing & Editorial Assistant Dana Friedman
ENTERPRISE COMPUTING GROUP EVENTS
Vice President, Events Brent Sutton
Senior Director, Operations Sara Ross
Senior Director, Event Marketing Merikay Marzoni
Events Sponsorship Sales Danna Vedder
Senior Manager, Events Danielle Potts
Coordinator, Event Marketing Michelle Cheng
Coordinator, Event Marketing Chantelle Wallace
Chief Executive Ofcer
Rajeev Kapur
Chief Operating Ofcer
Henry Allain
Vice President & Chief Financial Ofcer
Michael Rafter
Chief Technology Ofcer
Erik A. Lindgren
Executive Vice President
Michael J. Valenti
Chairman of the Board
Jeffrey S. Klein
General Manager Jeff Sandquist
Director Dan Fernandez
Editorial Director Mohammad Al-Sabt mmeditor@microsoft.com
Site Manager Kent Sharkey
Editorial Director, Enterprise Computing Group Scott Bekker
Editor in Chief Michael Desmond
Features Editor Sharon Terdeman
Features Editor Ed Zintel
Group Managing Editor Wendy Hernandez
Senior Contributing Editor Dr. James McCaffrey
Contributing Editors Dino Esposito, Frank La Vigne, Julie Lerman, Mark Michaelis,
Ted Neward, David S. Platt, Bruno Terkaly
Vice President, Art and Brand Design Scott Shultz
Art Director Joshua Gould
AUGUST 2016
VOLUME
31
NUMBER
8
magazine
0816msdn_Masthead_v1_2.indd 2 7/12/16 12:20 PM
msdn magazine
4
Writing good soware is hard. Managing the process of writing,
maintaining and delivering good software is even harder—
particularly when you add cross-platform mobile app development
to the mix. Which is why Microsoft has been so busy improv-
ing and extending its DevOps solutions, addressing the soware
development lifecycle from planning and development, to testing
and build, to deployment and monitoring.
Donovan Brown is a senior DevOps program manager at
Microso. He denes DevOps as “the union of people, process and
products to enable continuous delivery of value to our end users.”
at focus on value is important, as it goes beyond simple code
metrics to emphasize the tangible impact that delivered soware
has on the business, its workers and customers.
“To continuously deliver value implies that you are able to monitor
and validate that value is actually delivered,” he says. “Just copying
les to a server and hoping that people use them—there is no way
to quantify or even qualify if I delivered value.”
How serious is Microso about DevOps? Based on the company’s
$400 million-plus purchase of Xamarin in March and the acquisition
of tools-maker HockeyApp at the close of 2014—very. At the Build
conference in March, Brown demoed the extended DevOps capa-
bilities in the cloud-based Visual Studio Team Services tool. As he
told the audience before showing how the DevOps tool chain can
improve a mobile app development scenario: “I’m just going to rub
a little DevOps on it and make it better.”
Al Hilwa, program director for soware development research
at IDC, was impressed. “Microso wants its tools for developers to
be what Oce is for knowledge workers. at is, they want to be
the No. 1 toolchain for cross-platform development, mobile, cloud,
everything,” he says. “is is a tall order, but they are in fact exe-
cuting on it and building a multi-platform ecosystem. Given their
history with developers, you have to give them good odds on this.”
is is exciting stu. Features like Xamarin Test Cloud let developers
test app code against ranks of cloud-hosted smartphones and devices,
while HockeyApp provides a way to distribute pre-release code to
select groups of testers and receive both user feedback and app telemetry.
To help get ahead of it all, this month we’re launching the rst in
a series of articles focused on mobile DevOps, starting with Kraig
Brockschmidt’s feature, “From Code to Customer: Exploring Mobile
DevOps.” Also this month, the ALM Rangers team at Microso
shows how to leverage DevOps to build Visual Studio Team Services
Extensions, while Jonathan Waldman explores the integration of
Git source code management with Visual Studio 2015.
e Microso eort on DevOps is intriguing in that it promises
to li all boats. Every code writing eort, from traditional client-server
applications to Android- and iPhone-based mobile apps, stands
to improve within a robust DevOps environment.
What are your thoughts
on Microso’s DevOps push?
DevOps Directive
MICHAEL DESMOND
Editor’s NotE
© 2016 Microsoft Corporation. All rights reserved.
Complying with all applicable copyright laws is the responsibility of the user. Without limiting the rights under copyright, you are not permitted to reproduce, store, or introduce into a retrieval system MSDN Magazine or any part of MSDN
Magazine. If you have purchased or have otherwise properly acquired a copy of MSDN Magazine in paper format, you are permitted to physically transfer this paper copy in unmodied form. Otherwise, you are not permitted to transmit
copies of MSDN Magazine (or any part of MSDN Magazine) in any form or by any means without the express written permission of Microsoft Corporation.
A listing of Microsoft Corporation trademarks can be found at microsoft.com/library/toolbar/3.0/trademarks/en-us.mspx. Other trademarks or trade names mentioned herein are the property of their respective owners.
MSDN Magazine is published by 1105 Media, Inc. 1105 Media, Inc. is an independent company not afliated with Microsoft Corporation. Microsoft Corporation is solely responsible for the editorial contents of this magazine. The
recommendations and technical guidelines in MSDN Magazine are based on specic environments and congurations. These recommendations or guidelines may not apply to dissimilar congurations. Microsoft Corporation does not make
any representation or warranty, express or implied, with respect to any code or other information herein and disclaims any liability whatsoever for any use of such code or other information. MSDN Magazine, MSDN and Microsoft logos are
used by 1105 Media, Inc. under license from owner.
Visit us at msdn.microsoft.com/magazine. Questions, comments or suggestions for MSDN Magazine? Send them to the editor: mmeditor@microsoft.com.
Every code writing effort,
from traditional client-server
applications to Android- and
iPhone-based mobile apps,
stands to improve within a robust
DevOps environment.
0816msdn_DesmondEdNote_v3_4.indd 4 7/12/16 12:19 PM
msdn magazine
6
In recent installments of this column, I discussed what it takes to
build a Historical create, read, update, delete (H-CRUD). An
H-CRUD is a simple extension to classic CRUD where you use
two conceptually distinct data stores to persist the current state of
objects and all the events that happened during the lifetime of indi-
vidual objects. If you simply limit your vision to the data store that
contains the current state, then all is pretty much the same as with
classic CRUD. You have your customer records, your invoices, orders
and whatever else forms the data model for the business domain.
e key thing that’s going on here is that this summary data store
isn’t the primary data store you create, but is derived as a projection
from the data store of events. In other words, the essence of building
a historical CRUD is to save events as they happen and then infer
the current state of the system for whatever UI you need to create.
Designing your solution around business events is a relatively
new approach that’s gaining momentum, though there’s a long way
ahead for it to become the mainstream paradigm. Centering your
design on events is benecial because you never miss anything
that happens in the system; you can reread and replay events at
any time and build new projections on top of the same core data
for, say, business intelligence purposes. Even more interesting,
with events as an architect, you have the greatest chance to design
the system around the business-specic ubiquitous language. Well
beyond being a pillar of Domain-Driven Design (DDD), more
pragmatically the ubiquitous language is a great help to understand
the surrounding business domain and plan the most effective
architectural diagram of cooperating parts and internal dynamics
of tasks and workows.
e implementation of events you might have seen in my May
(
msdn.com/magazine/mt703431
) and June 2016 (
msdn.com/magazine/mt707524
)
columns was very simple and to some extent even simplistic. e
main purpose, though, was showing that any CRUD could be
turned into an H-CRUD with minimal eort and still gain some
benets from the introduction of business events. e H-CRUD
approach has some obvious overlapping with popular acronyms
and keywords of today such as CQRS and Event Sourcing. In this
column, I’ll take the idea of H-CRUD much further to make it merge
with the core idea of Event Sourcing. You’ll see how H-CRUD can
turn into an implementation made of commands, buses and events
that at rst might look like an overly complex way to do basic reads
and writes to a database.
One Event, Many Aggregates
In my opinion, one of the reasons soware is sometimes hard to write
on time and on budget is the lack of attention to the business language
spoken by the domain expert. Most of the time, acknowledging
requirements means mapping understood requirements to some
sort of relational data model. e business logic is then architected
to tunnel data between persistence and presentation, making any
necessary adjustments along the way. While imperfect, this pattern
worked for a long time and the number of cases where monu-
mental levels of complexity made it impractical were numerically
irrelevant and, anyway, brought to the formulation of DDD, is still
the most eective way to tackle any soware projects today.
Events are benecial here because they force a dierent form of
analysis of the domain, much more task-oriented and without the
urgency of working out the perfect relational model in which to save
data. When you look at events, though, cardinality is key. In H-CRUD
examples I discussed in past columns, I made an assumption that
could be quite dangerous if let go without further considerations
and explanation. In my examples, I used a one-to-one event-to-
aggregate association. In fact, I used the unique identier of the
aggregate being persisted as the foreign key to link events. To go
with the example of the article, whenever a room was booked, the
system logs a booking-created event that refers to a given booking ID.
To retrieve all events for an aggregate (that is, the booking) a query
on the events data store for the specied booking ID is sucient to
get all information. It denitely works, but it’s a rather simple sce-
nario. e danger is that when aspects of a simple scenario become
a common practice, you typically move from a simple solution to a
simplistic solution. And this isn’t exactly a good thing.
Beyond CRUD: Commands, Events and Bus
Cutting EdgE
DINO ESPOSITO
The real cardinality of the event/
aggregate association is written
in the ubiquitous language of the
business domain.
Most of the time, acknowledging
requirements means mapping
understood requirements to
some relational data model.
0816msdn_EspositoCEdge_v6_6-9.indd 6 7/12/16 12:27 PM