sometimes you want to suggest extensions
to your colleagues and they could be
extensions that are publicly available
but you want to create a little list for
them so they have something that to
choose from that you know or a good
extensions that will help them and all
the times you might have extensions for
registered that you have built
internally in your company that you want
to share with everyone but you don't
want to upload them to the marketplace
which is a place where everyone in the
world can then use them you want to keep
them internally to your company so let's
take a look at how private galleries can
solve both of those problems relatively
easily and what we really want to do is
we want to get in here into the
extension manager dialog and if you look
here under the online tap you can see
that there's the visual studio
marketplace all right so that's the
global one we want to get our own custom
one in here next to it so first of all I
need to get a bunch of extensions that I
want to have part of my sort of private
marketplace or gallery and I have that
here I have a bunch of extensions that
I've put into a folder and in order for
me to share this I might have put that
folder on a on a network share so
everyone in the company or my team has
access to it I also put an X II file in
here called private gallery creator and
I got that from github so if you go to
get up the private gallery creator repo
there's a link below here in the
description you can go to releases and
just download the exe file directly from
here now
what that allows me to do is simply just
double click and that will start the
console app and it will produce a feed
an XML atom feed based on these
extensions and if there are if some of
these extensions are particularly big or
flex it could take a little bit of a
time and others are super fast so it's
now done and we can see that we now have
an XML file we also have a hidden folder
here with icons in it so it extracted
the icons out
so this feed is consumable by visual
studio let's take a look at how we do
that so I go to extensions up here and
here at the bottom of dialog I'm just
gonna click change your settings for
extensions and then I'm going to add an
additional extension gallery I'm gonna
call it my gallery and the URL is the
feed this file right here so I'm going
to hold down shift and right click and
that's gonna give me an option here
called copy s path and then I'm gonna go
back into visual studio paste that in
and remove the quotation marks that is
automatically being inserted here like
that hit apply and okay so now when I go
into my extension manager dialog you can
see that there's now a my gallery right
here and that lists all the extensions
that I have in that feed that I have on
my network share where everyone can
access them if these extensions that I
have in my custom feed also exists on
the marketplace then Auto update will
happen automatically regardless of which
of the feeds the visual studio
marketplace feed or the my gallery feed
whichever one has the newest version
visual studio will update the extension
from there so you don't actually have to
maintain the local gallery with always
with the latest versions if they're also
on the marketplace then the users will
automatically get the updates so that's
how you do that and there's a lot more
if you go into that github repo you can
read a lot more about how this works
what are the different options you can
call the
the EXCI with to have it automatically
create the you know a new feed whenever
a new v6 file is updated on disk and all
these different parameters you can use
to customize and ultimately get the
exact behavior that you want for your
custom feed I hope that was helpful
thanks for watching
Wednesday, February 4, 2026
Create your own Visual Studio extension gallery
Customize the toolbars in Visual Studio
Customizing the toolbars in Visual Studio
for your workflow and personal preference
can have a great impact on your productivity.
Best of all, it takes no time to do.
Now I've been using Visual Studio
for years, and I know the keyboard
shortcuts for the most common commands; so
I don't need them visible on the toolbar.
I start by opening the add and remove buttons menu
located on the right hand side of all toolbars.
Now I can start unchecking the
commands I don't want to be visible.
I use a lot of extensions, so I'd like to add the
Manage Extensions command so I simply check it.
Now my toolbar is a lot more my style,
but I want to add a command that
wasn't in the menu we just saw.
To do that, I'll click the customize button
to open the Customize Commands dialog.
Here, I can easily add any
command to any toolbar or menu.
I simply navigate around the menu system
to find the command I want - it's listed in
alphabetical order and I want the options command.
I click OK and it's inserted
into my toolbar - it's that easy.
Database DevOps with Redgate Data Tools
hi welcome Visual Studio toolbox I'm
your host Robert Greene and joining me
today from bill that the beautiful
Washington State Convention Center is
Steve Jones from red gate thank you and
today special guest co-host mr. Scott
Klein renko's remember we are going to
be talking about data today and
specifically database DevOps yes red
gate provides some database DevOps
tools inside Visual Studio Enterprise so
we're going to talk about those you're
going to do some demos yes but we're
going to start off by explaining this
concept of database DevOps
all right we talked about DevOps all the
time continuous integration continuous
deployment pipelines fast cadence you
know lots of quick releases and we
talked about it from code but apparently
it applies to databases as well no we
don't you know ready to spend a lot of
time in the last five six seven years
evolving our tools to try to support
more rapid database development you know
as much as we've studied the DevOps
movement that continuous delivery stuff
the things that Mountain Martin Fowler
talked about they always leave the
database out because the database is a
challenge the database has to maintain
state from time to time to time right
unlike code where we could just replace
a DLL or an XE in the database I can't
just drop those tables I mean my life
would be easy if I could write life
would be great but you can't just invent
a new engine to dry it out a B testing
did people actually want a person class
in this application well some do some
don't so we'll we'll cut that out it's
easy in code right it's been yeah for
developers but for the database people
it's more difficult and I think that's
led to the hesitation from database
people to move faster but certainly all
the application developers you've got to
move fast you've got to deploy code I've
got to deploy enhancements and then
often means I need a place to store some
of that data so Red Gate is working to
try to get the database to move just as
fast as the application so give us an
example a real-world example of what
that might look like how is it database
changing so here's a great example we
all know security is a big deal right
never seen data breaches every week
we've got all these problems all the
time
there are plenty of customers that are
starting to do things like implement
encryption into their system so I want
to implement always encrypted on to a
database platform so over you know
PayPal whatever ecommerce I'm doing so
I've got to field that story and perhaps
credit card numbers or emails or
something else and I want to implement
that quickly well it takes time it's
difficult to do encryption so one of the
things I might do is I might add a new
column that will support that encryption
so I will do encrypted data there but my
application has to run 24/7 right so
what I do is I build a view on top of
this table that contains the old column
that's still there and I put a case
statement in there some type of switch
that says if I have encrypted data we'll
send that back and the client will deal
with the encryption and always encrypted
but if I haven't got encryption because
one of my applications isn't there let's
send the old column back that isn't
encrypted okay so in a 24/7 environment
I can evolve my database quickly using a
devops process keep it running at the
same time meet the new requirements that
I have for security for anything else
cool so it's not like you're inventing
entirely new tables changing the basic
structure but it's more incremental
changes to support incremental
functionality your needs exactly you
know in the database DBAs have been
hesitant to make changes because I've
been a DBA in my career and we're
responsible for stability and
availability and performance and so we
get nervous about changes not that and
you don't write good code but every once
in a while it's a little freaky so we
get hesitant which means we try to delay
deployments we try to stack things
together get lots of changes right which
increases my risk yeah and it means I've
got to make a bunch of changes at once
and that's the opposite what we want to
do in DevOps right you developers we
want to deploy often I want to be able
to make a new branch write some code do
a pull request have somebody prove it
deploy that next week or deploy that
tomorrow and we want the database to
follow along and so I've done that a lot
of my career and Red Gate has really
spent a lot of time to try to help do
that as well mm-hmm could we back up
just a second because you and I were
asking about this I'm like if DevOps is
understood I think primarily by
developers right right but if I'm a
sequel person you know what is this very
very simple what is
and what does that mean to me for no
good because I really how many how many
sequel people really understand what is
what it means yeah what about
I mean DevOps is kind of amorphous like
the cloud there isn't necessarily this
definite definition what it is it's
adhering to these principles that I
followed for most of my career when I've
done Six Sigma or ISO Tiger software I
want to learn and I want to become
better every time I want to keep my risk
to a minimum and I want to adapt process
around what I do all right a lot of what
we do in DevOps when we do continuous
integration continuous delivery we do
instrumentation telemetry is we're
adding process but we're doing in a very
lightweight non intrusive way so we're
trying to do a database as well so that
you can make your changes you can deploy
them out in smaller increments and have
them work with less risk now there's no
magic right there's no magic to making
database changes all we're doing with
DevOps is we're really automating the
things you would normally do yep in
trying to wrap them in a process so
they're reliable and repeatable because
ultimately we as humans we're not
reliable repeatable we're very creative
we get paid to solve problems and
compose solutions but we have to do the
same thing over and over and over again
okay we're bad and what we're trying to
do with DevOps is try to implement some
process that makes it repeatable and
reliable yeah cool all right yeah we see
some things happen absolutely demo time
demo time so I've got Visual Studio
Enterprise on my machine and in the box
Red Gate is shifting is shipping a ready
roll core product and ready roll is one
way of performing database development
and we built it as a project that's a
first-class project just like the
database projects that are in SSD T and
so when you implement this it's very
similar to that project now ready roll
works in what's called the migrations
based development framework where we
track every changes so if I look over
here I've got all these migration
scripts and each one of these is just a
different set of data scripts that I
would run in development as a developer
database developer or a full-stack
developer I would just kind of make some
of these changes and what ready roll is
doing is kind of tracking them as we go
along and so that when we deploy them we
execute them the same way mm-hmm now
it's just it's it's kind of
philosophically different from SSD T or
some of the other Red Gate products and
that those work in a state based world
where we can
the state of the database the state of
the development at and we come up with
the script yeah right so this is kind of
tracking one by one yeah let's spend a
little bit more time on that because
there are the sequel server database
tools yeah the Redgate tools which ship
in the box because although you do they
don't just install by default but you
can go to the individual components and
get out the work there they are
so talk to us a little bit more about
this state versus migration approach in
the state but I complementary or they
you don't know the other they're kind of
opposite you know Redgate got started
with sequel compare which is a schema
comparison that tool that is very
similar to what's an SSD to and in the
state based world we make a bunch of
changes just like I might do in c-sharp
or Java or something else and then I
take those changes and I compare those
changes with what my production database
looks okay and then I develop a script
kind of in real time a dynamic script so
kind of like with things we would do an
application program it's kind of like
run time versus design time okay so in
the state based world you do that and
that's fine and it works great for so
many people people use read gates to
compare to do that they use SSD to do
that and it's great the problem is
there's a domain of problems that you
can't solve with the state-based
comparison so if I rename something how
do I know I renamed it is it a drop-in
ad or a rename I'd if I add a not know
column there's data manipulation
involved I can't solve that problem so
there's a class of problems that
state-based comparison doesn't solve
right in SSD T people use pre post
scripts to get around them with red gate
OU's will use one called migration
scripts to get around it but it's just
one way of development again in my past
I've worked in Oracle db2 world and a
lot of those larger systems older
systems have worked in migrations world
where they go every script you write
every change you make the database we
track that so when I go to upgrade I run
script one and then two and then three
and then four and then 56 or 57 to 58
and it's a bulletproof way of doing
deployment but it can be cumbersome and
time consuming because the other thing
is if I add a column to a table drop a
comment table add a different column all
three of those things run in production
on my development database with ten rows
data who care
my production database with the billion
Reza data slightly problematic yeah so
neither one is perfect they both have
pros and cons they're just different
ways of working at the world and
throughout my career I've been working a
sequencer for 25 years now what I find
is that people fundamentally fall into
one of two camps either like state-based
like SS PT and sequel compare or they
liked migrations like ready roll or
liquid-based Flyway DB DB up various
frameworks antenna is this a kind of a
thought shift as we you know you've been
talking about database compare you know
schema compare an SSD teen things like
that I is this a shift and how I think
about working with databases now from a
you know because because we have all
these people like yep no schema compare
I know SSD T but now we're you know
ready roll and I'm like how do we get
people you know start thinking down
those I think just philosophically you
decide you I'm going to develop one way
or the other
okay it's kind of like saying you know
do i mix functional programming an
object-oriented I don't I kind of choose
one or the other and I have either some
philosophical leaning or I have some
requirement that says we should go one
way the other in the database world it's
the same thing it's just neither one is
better than the other one they both have
pros and cons they both have workaround
yep and but it is one more of a best
practice type of thing no I mean there's
advantage so one of the things we love
when I've worked in like Oracle
financials with large ERP systems is
that when I do migrations based of LMA I
can take any birds in the database and
upgrade it to any other version because
I have all the scripts obviously all
right so if I have clients at version 2
and version 3 and version 4 I can give
them the same set of scripts and get to
version 5 and that's easy in the SSD tea
world I need custom scripts for every
version right ok so there's pros and
cons the other side is I'm tracking all
these scraps right ok
some developers hate this correct and
some some don't like the state based
thing because they're not confident that
will actually develop all the changes
employed right so it it's not really a
shift it's an option so ready roles are
giving us an option for people that
prefer this it's how we actually think
about things you got actually okay all
right so let me make a couple changes so
we were in Visual Studio ready roll is a
part of Visual Studio it ships in the
box
for enterprise there's various things
you might want to do some people like to
work in Visual Studio so no it doesn't
like that let's see if it'll work this
time
let's forget let's do it this way
because I'm a code guy so I don't mind
writing code so let's create a new table
we'll call it channel 9 and I'm here
with Robert
he's an inn in Scott he's a would make
you a masquerade of Archer yeah but back
to your max all right so I can I have a
reliable type if I can run it very kind
of on a path and you're just fly deeper
yes so you're there I can't anyway I'm
getting from this you know I've got this
I've got this table here that's got a
feeds in it let's add a new feed so it
feeds into one of the things we also
subdivisions to enterprises is single
prompt core which is our intellisense
version and it's pretty good so we'll
add another feed in there and then
because we know some people like to work
in management studio we can always work
in management studio as well so I can
pick up changes here so let's pick
something in my development database
here and let's pick some stored
procedure in here and let's just pick
this one so here's a stored procedure
and here's one of the other things about
sequel code that makes it life difficult
is this code is fundamentally different
from the code I used to build a sore
procedure right because I would actually
have to have a create here to build the
stored procedure but instead I need an
alter mm-hmm right when I build a class
in c-sharp when I say you know public
void class yeah that code always looks
like that I mean yeah right whether I
add or subtract the code fundamentally
the same in here it's different but in
this case let's change something let's
actually do a best practice and we'll
just pick up some of these columns and
rather than the select star we'll do
this and I'll execute this so I've made
a bunch of changes here now so in ready
roll one of the things we do is we've
added a pane here and what this does is
allows me to kind of
for any of the changes that I've made
and once I've done them you'll see it's
detected number of changes and when I
import these it's actually going to add
them to the project and so what we'll
actually get I'll refresh it to make
sure everything is added we've added
some different scripts here so those
migrations are records it's a record of
changes that you have made in the
database that are ultimately going to
need to be propagated or published or
whatever look exactly - so this script
a17 here is my insert right we've added
that in there and my script 16 is that
well either table I think was somewhere
else maybe it's in here stole but I've
added these scripts in here and so they
exist as part of my project they're
under source control so exactly and so
we're trying to do is treat this exactly
like our code so in this case I've
actually just got new code here that
I've added right so I can like anything
else I can add it so added channel them
and I can do what I want to do just like
I might do in Visual Studio is I've got
my board here and visuals media where
I'm tracking work so I can I can use
this pound syntax to actually add commit
and push my changes so part of what
we're trying to do is ready roll is
implement the database just like we did
any other code and actually track this
stuff and I think that's that sort of
answers the question that we asked at
the beginning what does it mean to be
database DevOps is it just as you make
changes to an application in code and
you want to be able to manage those
efficiently you make changes to the
database right I want to treat that the
same ways right so we want to add those
in there and so one of the things I've
also done here is that we're actually
running a build in the background so
I've actually got a Visual Studio agent
running on its machine it's actually
running a build right now so just like
we would do with our c-sharp code or
vb.net code when we submit it in we want
visual studio team services to actually
be running and if I look here I should
see my build just succeeded I think
and I've got all the information in here
that looks at like what I would expect
I've got test coverage running and you
can zoom ibly break the build because
you made database changes that are that
are violating some rule or didn't quite
work out or something right I mean one
of the things we want to do with DevOps
is we're trying to pull all of our code
together and determine very quickly if
we've made a mistake right because
that's a risk issue so here I can pull
this in I can run my build and if I look
at the definition this is just a visual
studio build task there's nothing
special about what this is right
I could I could have this building
c-sharp as well if I was doing it and
then I run tests in this case I'm using
the Microsoft test framework to actually
run tests like a what does the building
test actually do didn't like take those
scripts to a like a sample database and
run those and say yep that's exactly
what the old will actually rerun those
scripts against a temporary database and
determine if they're valid sequel all my
object reference I resolve all the
things like that the test is just a test
like you would run for anything else
right there's the written T sequel but
but I set up a test and I say you know
check this value run this query see if
the results match right and go from
there
and so once I do that I just output an
artifact and just like any other code
I've done that okay in this case I've
actually I'm committing out to a release
process as well so we're doing
continuous delivery so one of the things
that we want to do here and I want to
say my build it succeeded a minute ago
so I should see up here a release to
integration that just ran and so if I
were to actually go back over here and
let's change the integration database
and let's say I've got that feed that we
just added and I didn't change that in
this database or I didn't do anything
else and as a matter of fact let me go
further let's pop over here to QA and
let's look at QA now if that doesn't
exist yet but let's make it exist so
here I have the ability I have these
downstream releases as well and Scott
will let you Scott watch me so I'm not
going to use the keyboard as well all
right we'll put the keyboard away and
the creative release
and I'm going to say release this and so
without using the keyboard at all we're
going to see this database change deploy
to another database right look ma no
hands nothing out of my videos if in a
second this will be run yeah and as a
matter of fact let's come over here
we'll execute this
I think it's deploying right now and we
should see that data changed actually in
here and we would see the other change
as well if we wanted to go through that
right click we're in the process there
it is so here we are in the QA database
right you saw me I didn't touch the
keyboard a topaz at all and we've
deployed this in the same way that we do
all our code and again when I look at
this release definition this looks like
I would deploy a asp.net web app to
Azure or a mobile application anything
else in this case I've got multiple
environments that I'm deploying to I've
got these tasks that I put in here in
these case these are tasks from red
gates that allow you to do that and just
deploy all my code what's the what's the
set up time for if I wanted to set
everything you showed what's the setup
time that would take me to you know
properly set up a DevOps environment
properly so that would benefit yep so to
set up the entire environment
technically from the technical
standpoint we could do it in less than
an hour as a matter of fact I do talks
all the time where we'll take we'll go
from scratch and we'll import a database
into a project and we'll set up C I will
commit it to version control setup CD
and we'll do it the cultural changes are
hard to write because everybody has to
get used to understand so I'll discuss
from the technical standpoint I think
the the other aspect you know the now
getting me to use this process is the
not the hour it's right it's every month
because we don't realize I think
sometimes all the little steps that we
make as humans when we're trying to
deploy code okay and we see this when
I'm trying to deploy to Azure if we take
the sample apps and I deploy asp.net
j''r now I can use yeoman or something
and be done in ten minutes right but in
terms of getting all my code out there
and realizing well I really need to make
sure that I've setup firewalling and
that I'm actually deploying this extra
bit of code that's side to my project
and I've got to config that all those
little
changes are what take time but that's
part of DevOps because we're learning as
we go and so we start to make those
changes right right so where would
somebody go to learn more about database
DevOps so we do a lot of work at Red
Gate I run sequel server central we do
some work there where we're publishing
information and then I'm working on a
course for MS learning right now and
hopefully we'll be done in June on my
travel schedule but at open EDX
Microsoft com
Microsoft is publishing a huge series on
DevOps and AD and all sorts of languages
platforms different things and we hope
in June have a database DevOps course
out there that will give you more
information about how you can work with
state-based with migration based with
open source platforms or sequel server
with whatever you want okay so the the
tooling that ships in Visual Studio
Enterprise is it a trial is it a no it's
a harder version it's a real deal
yeah it's an untimed version what we
have there is a Visual Studio Enterprise
contains ready role core and sequel
prompt core and sequel source 3 red gate
products ok the sequel prompt and the
ready role cores have a few less
features than we have in our full
product and but you can upgrade out
there they're not trials they're full
versions that will allow you to do this
deployment and development you know as
much as you want so can't visual studio
enterprise and then what is sequel
search so sequel search is just a full
search product that lets you go
throughout your database and find
objects in a more intuitive and flexible
way than what ships in management studio
ok all right I'll be honest how many
people know that these products are in
because I had no idea sounds to connect
so if you were paying attention
thanks for calling that out Robert well
it's amazing visuals did you have 2017
that there's all these different
workloads and you don't realize
sometimes that you know if you don't get
that mobile workload you don't get
xamarin in there and if yeah the data
workload you don't get ready roll and
and there's various workloads so you
should definitely look at the visual
studio installer and look at all the
different workloads that route 58 vision
mm 15 and 17 just 17 just say okay
that's dozens that's why because I
haven't looked in 17 yet and 15 okay so
17 only said Isis has changed okay I
feel redeemed now yeah one last thing I
just wanted to talk to you about briefly
one of the things that developers always
want to do is we we want more data we
want to work on real data right because
it helps us do an application and often
if we just use the ten rows of data that
I feel like typing that day yeah I don't
get a good feel for whether my
application works with the data is in
production or its scale or anything else
so red gates been working on a product
that we just released called sequel
clone that allows me to make copies of
full-size databases and use very little
space so if I jump over to my screen
real quick one of the things we'll see
is I've got a production database here
and it's got three hundred Meg's so it's
not big but you know for my laptop
that's decent size but I built these
clones and these are real copies of that
300 Meg but each one is only using 48
megabytes of disk space and that 48
megabytes is fairly constant even if
this was a terabyte database yeah and
and I have the ability to quickly create
a clone so on this machine I can create
a clone and I'll say we'll call this
Scott because Scott's my friend and I'm
going to create that 300 megabyte mark
here in an eye out five six seven
seconds I've got a copy database and if
I look it over here in my management
studio we've got the Scott database how
big how big was it 40 Meg's so I've got
all my rows actually let's take that top
out of there I try not to break things
too often but so I've got thousand rows
in here yeah and if we look at this
Scott it is a full-blown database full
database so if I look at the properties
database this says it's 270 Meg and 60
Meg okay but on disk this has only taken
48 Meg of space Wow Wow
so I could we can do right now at the
two terabytes because we're using VHD
files but very soon we'll have up to the
64 terabytes VHDX files but we can make
copies of those databases with you know
roughly 50 70 Meg on your laptop and
allow you to get access to that full
size database and then what are you
impressing that how you getting there
know is that the secret sauce you can't
there's definitely a secret sauce it's a
little bit magic and unicorn dust on
there but really what we do is we take a
point in time snapshot of our database
and then we have a central copy of that
and we're all reading from ok and so
it's a similar data virtualization
technology company - ok but Redgate has
brought it to the sequel server platform
at a very low cost and it allows you to
give every developer copies of the real
database and if I don't like this
database I can delete it in seconds and
I can create a new one now if I've
updated the data and I want to do
something else I can do a new one in
about where we say 7 seconds and we'll
call this one Robert and I'll build
another database on seconds and then I
can just go ahead and work with that and
be ready to go that is very cool cool
well thanks so much for coming on thank
you very much for having me so we've
seen a good overview of what I need a
base DevOps is I've learned a lot this
tool that you can that shipping
Enterprise go to go back into the
Installer and go into the individual
components tab and find them there there
they are playing around with it and
learn yeah that's your homework
assignment everybody yeah give it a try
yep thanks hope you enjoyed that and we
will see you next time on visual studio
toolbox
Database DevOps with Redgate ReadyRoll
hi welcome Visual Studio toolbox I'm
your host Robert Greene and joining me
today is Steve Jones from red gate hi
Steve is here to talk about database
DevOps that's right and we we chatted it
build I we did a show it build and we
covered some of this stuff then but
we're gonna do it in a bit of a more
deep dive and get a little bit more into
the meat behind it okay ah right yeah
absolutely
so we're gonna talk about two things
we're gonna talk about two different
ways of doing the database DevOps first
that we're going to cover today is
migrations and then the second one is
database compare right data compare have
you ever done migrations when you've
developed yes yep do you like migrations
do I like migrations it's a to doing
stuff gets done so I like I like stuff
that works but I don't have a passion
one way or another for it let's go that
way yeah I find a lot of people don't
either do it don't like migrations I
I've done a lot of migrations more in
the Oracle and db2 world where you know
large ERP systems often just track all
the scripts there hundreds of developers
right and then we run them all in order
and it always works but it can be really
slow sometimes okay so some people don't
like migrations but I prefer it you know
and I work for regular software we we
support both ways of doing database
development well so whatever works for
you that's fine and maybe you'll pick
one or the other after this but at least
I'll learn how they both work right the
exact wording it said at the end of
these two parts all right all right
migrations first so migrations first
let's back up a step okay we dive in
what are we doing so I'm a database
person I've been a sequel server a
person for most of my career I've
actually been working sequel server for
26 years now so more than half my life
has been spent working with databases
right so it's kind of amazing that
throughout that time I've developed
software in a number of different ways
as a DBA and developer and so I've tried
to work through these different ways of
efficiently getting database changes to
action making sure that I'm not
interrupting an application I'm not
causing downtime unnecessarily
certainly I'm not causing any data
integrity issues or losing anything
along the way right so you know you make
code changes all the time but you're
saying that how often do people make
database changes not as much as code
changes obviously not as much as code
changes right the database because we
have to maintain that state of our data
mmm like unlike an application right I
can drop a class I can add a method I
can make these changes and I kind of
just replace different versions of right
maxi's dll's assemblies resources
whatever it is I can do that with some
of my code in the database world my
views my procedures things like that but
my tables I have to keep around so I'm
always kind of evolving them okay and
because I have to do that especially as
my database grows larger I want to be
careful how often I make those changes
okay renaming a table is disruptive
because unlike renaming something in
Visual Studio the compiler can find all
the references or the IDE can find all
the references and do that for database
I am xions coming from various
places and I don't know what's happening
right so I think it depends on a lot of
times the maturity of your application
if you're starting out you may make more
database changes than later yeah right
okay as I grow I get a lot of technical
debt kind of in my database world
because of all those connections to
other applications reports ETL systems
all right so I'm hesitant to make this
changes okay now there are people that
do a lot of additive changes where they
just add things to the tables they add
systems to the objects to the database
so that they don't hopefully don't
disrupt those applications all right and
they can continue to add features and
functionality throughout the lifetime of
their application ok so one of the
things that you know I've been doing
really for most of my life is a lot of
things we call DevOps when I trying to
have lightweight processes that work
that helped me make changes in an
efficient manner without causing
problems and at last 3 or 4 years all of
a sudden we have a name we call it
Devil's we DevOps all the things now I
think that's Donovan Brown might say
yeah so so maybe I show you some things
here I work for red gate software and we
have ready role as included in Visual
Studio Enterprise yeah so that's part of
what's there and I have a little ready
role toolbar here that comes up and
that's a pain in Visual Studio and my
project in ready role is just like any
other project so if I were to create a
new project here and since we don't want
to run through everything ready role
appears just like my database project
would for SSD T or for a c-sharp or any
other type of application we have in
Visual Studio in this case the ready
role project builds off of a database
project which is slow to come up but you
can see that there's database projects
like we would do and for SSD teeth for
Daniel's or I've got ready role projects
here and the difference is the database
project works as tracking all the
changes and then it does a comparison
with sequel package and you'll deploy
those changes mm-hmm I kind of package
everything I'm a backpack and ready roll
we have what we call migrations
so in this existing projects I've made a
bunch of changes over time you can see
I've got all these scripts and each one
of these is just a change that I made to
my database as I was performing
development so in this case I'm altering
the table obviously I can't you wrote
the scripts and then saved them in the
project right yep I actually have a
couple ways of doing it I can import
those changes if I've made this in
management studio or another developer
made changes so I can
ensure that I'm capturing all the
changes or I could write the script
directly okay so ready roll what it does
is it takes the burden off of you of
trying to manually grab every script
make sure you've caught all the changes
giving it a name saving it off right
okay so I can do that so over time I
just collect these different changes
that could be DDL changes they could be
DML changes there's just a series of
things that I'm doing to my database I'm
creating objects I'm altering objects
whatever is appropriate for my
application so in this case this is a
common pattern that in the SSD T world
or in a state-based comparison world is
difficult to handle I've got to add a
notnot column I'm gonna I've got data in
my table right so I can't add it not no
column right I have to add a no column
update some data and then add a not null
right
so that's a complex change they still
haven't changed that that way forever
right yeah I mean there are ways around
there I could add a default I could do
some things but for a lot of systems
I've worked with a lot of developers
this is a problematic item because I
don't want to default value what I need
to do is populate that appropriately
with some value that matters for that
room okay so ready roll makes these
types of changes much more robust and
resilient so where's the migration ID
come from there so let me show you how
this is done will create a migration
script now so if I want to create a new
script I could certainly just right
click and add like anything else mm-hmm
I could certainly add a stored procedure
or a table or anything that I want to do
so when I do my development is the
migration ID that gets created when you
create the script that gets created a
great degree okay so it gives me a
unique way of identifying this script
and tracking whether it's been deployed
in the environment okay no so we do that
so let me create a little procedure here
that I want to do and I'll just give me
something that I can run okay and I can
certainly run this if I want I have a
variety of options like I would in any
other database development that I'm
doing that I can just mark my code run
it test it to everything that need to do
here yep this has been executed on a
local instance it actually exists there
so I can run any my application against
it I have all the ability to do the work
that I do normally as a database
developer mm-hm and then you know
periodically what I want to do is I want
to make sure that I've deployed
everything in my project so I can click
here and it'll do a build in Visual
Studio like anything else so I know that
popped quickly up there but I actually
have conflict and something failed
already an object name get 10 yeah yeah
okay cool so it thinks it's still there
I don't think that's the case let's just
check I'm more comfortable you gonna
believe Who am I gonna believe it does
exist
I think cuz I ran it and then I said it
was deployed let's deploy it again into
a build because I'm a developer I'm
human I make mistakes right things
happen as I'm going let's see it
deployed it succeeded everything
at all so I can kind of see what's going
on in my project as I'm performing
development because I have the code in
scripts I could certainly check the
database against this
I've got everything like I would
normally have this migration ID is is
how the framework will actually check if
this script has been run okay so inside
of my database we actually track that so
if I pop over here and let's just check
it from here there's migration log and
we can see here that this contains all
of the migrations that have been run so
there's this good that we have there's a
checksum make sure that the script I
think Iran is the correct script right I
haven't edited or changed it and I have
the file name and then various other
metadata that lets me know what's going
on so this ensures that my scripts in
essence will only run once so I can't do
something like add data in a script and
then worry about it being added again
right duplicate data recreating tables
that kind of thing so so far as I go
through database development it's
similar to what I might do in c-sharp or
any other language right right that I'm
just kind of working with my project and
make your changes and like any other
change this kind of appears as part of
my team Explorer right I've hooked up to
version control which is one of those
things that I find so many database
developers don't do right they don't
track their DDF right you've deployed
this to the database already my
development database all right so I'm
working with an in development database
and I've got this change out there
mm-hmm
okay and I and I can certainly make
other changes and let me show you
something else cuz do you find there's a
lot of developers that like to work in
managed studio still because it's a
comfortable way of working and it's
quick so let me add a piece of data here
to this table and if I look at what's in
here I've got some data in there so I
just add in row number five so one of
the things ready roll also allows to do
is track reference data or static data
that I might want to include as I deploy
this further mm-hmm so here's here's a
value that I want to include well once
I've done that and ready roll what I
want appear like to do is check if I as
anybody made any changes
Visual Studio certainly I could have
just done run a query on Visual Studio
as well that did that same insert we can
see here that I've actually detected
there's a data change here and in fact
this one row that was inserted so I can
add this as another script and this will
come in as another migration script
this is script 32 it's got a different
migration ID which you'll have to trust
me that's the case we won't compare the
height but Randy Rahal has built me an
insert statement it could build me an
update statement it could build me a
delete statement whatever would be
appropriate here and again that's here
inside of the change team explorers
whoo-hoo so all of this is my local
development as the database developer my
laptop my workstation I'm doing my thing
right so are you committing this to
version control as a way of keeping
track of the history because these you
changed the database right it's a little
bit different than writing code it's a
little bit isn't it it's a little
different right because certainly
anything I do to a table or to data has
to is kind of this evolutionary change
of thing that I'm moving from one state
to the next constantly I'm tracking it
in version control a because I make
mistakes sometimes I have to go
backwards okay just the way the world
sometimes I will misinterpret
requirement the business person will
tell me the wrong requirement and we
will write code and realize it doesn't
work we can roll back the database
changes well we can certainly find out
what we changed I can go back I can
certainly go to version control and grab
those changes
rolling back database changes is not
always easy yeah cause it's not like the
data's in source control the history the
data it's not go back to a snapshot
right now for stored procedures and
functions of use I can just grab that
previous cousin right cuz those are just
code those are just yes okay for tables
I haven't come across a tool yet Norway
I think would I trust my job to a tool
to roll back my date right change
exactly right because if that if there's
been data added to the table I need to
decide what to do with that day
right if I've dropped a column which is
a very dangerous thing I need to have
prepared for that advance because
nothing is rolling bringing me that
table change back right right okay so
those are different but as much as
possible I'm trying to treat all my
database code like application code mhm
okay and part of this is that I want to
use this code to move forward to do CI
and do CDJ like I would do with an
application okay so let me commit this
you'll see this out there actually
before I commit this let's just go look
I've got a project out here in visual
studio team services which i think is
fantastic by the way
mm-hm I think you're right it is this is
maybe the best developer tool I've seen
Microsoft ever build
now the visual studio team service is
just amazing really is and I use it all
the time so I've got you know a board
like I would have for anything else and
I can track all my database work yeah
and I've got my codes here as well and
I've got my project so I've got my main
database project my test project because
I want to test things you know in
various items and if I flipped down in
here and look at my migrations and my
last change was this morning right a
little while ago we were checking things
out let's go ahead and commit this
change so we'll say channel 9 Robert
I'll call it one let's commit and push
that so once I do that this will
actually push up into the Microsoft the
first time I looked closely at that
drop-down and saw that commit and push
you could do all the ones instead of
committing and then going and finding
push this that might be like the one
thing I wish existed instead of a
drop-down it would just give me the
option to remember that would that be
even better right yeah but if I let's
refresh this so that I see what's out
there
I should see we just pushed out two
changes okay so it tracked to new
scripts yep and now I have a history of
what's going on because in a migrations
world I'm tracking all these scripts
over time so that's an interesting best
practice you've got two changes in one
comment so given that you're all the
rest of your comments are pretty
descript
give would you then typically just
commit one script at a time it depends
on the work that I'm doing at that you
know III that's kind of a devil of a
developer philosophical question right
do I include multiple changes into one
commit mm-hmm I would have that option
just like I do with anything in Visual
Studio I could pair and choose what
commits in this case if I was if that
data change was associated with the
stored procedure change I would probably
commit them together with the work item
in a better description of Christ right
not a great comment but if they were
separate items as is the case sometimes
in database world mm-hmm I would make
two separate commits okay and and that's
one that's one of those things that
comes along with you being a developer
learning how to commit in batches or
singly as appropriate yeah that takes
your experience there okay so we can
make our changes here and commit them
but we want to go farther right because
this is a great safety net in version
control but it's not helping me build
software faster mm-hmm it's not help me
build software better right so I want to
make sure that I'm actually building
things as well and the build system
visual studio team services fantastic as
well I mean I've watched people build
all kinds of stuff here mmm that from
from Java to Python to c-sharp to
database everything right it's just
amazing and we can see here we've
actually just built a new building so
when you created that build was there a
built-in template that you got to select
or did you have to build it from scratch
I actually built it from scratch now
those of you haven't used Visual Studio
Team Services give it a try
but it's a very simple project yeah just
like you would do for c-sharp I'm doing
a visual studio build and this is just
the standard Visual Studio build tasks
so okay so you named that my name right
so I can I can change the name right and
right here in the display okay this is
the standard Visual Studio build task
okay so if there were if I was doing
c-sharp in the same solution right let's
not restart now that's not to go
so if I were doing a c-sharp project in
the same solution I could build it here
I could have two Visual Studio builds
this intended each project separately
whatever is appropriate for my system
but you know I'm doing the same solution
build you know I've specified the name
I've got the MS build arguments just
like I would normally have okay
ready roll wants to build against
another database a target database where
I'm going to deploy to so I give it a
parameter station where am I going to
deploy so here's a question so when you
wrote the script you deployed it so you
already changed the database correct now
you've got a continuous integration
build what is that doing so what it's
doing is is going through and
re-evaluating the entire script to make
sure that everything's correct it's
looking against a downstream environment
that I would want to send it to you to
evaluate which of these changes maybe
you just changed the like a development
database yes confirm that it all works
and now you're using the CI process to
update the production database or
further downstream database I'm doing a
downstream data so I never I always like
to work in multiple environments in
these days with containers of
virtualization and VMs I always try to
have at least three environments if not
more so in this case I've actually got
five so one of the things I want to do
is I'll make my changes but you want to
be able to see my changes right or we
want to see all of our code together
just like we would in a c-sharp project
and web app so in this build what I'm
actually doing is I'm building and I'm
running my tests mm-hmm so I'm seeing
I've got the Microsoft unit testing
project as part of this so I'm running
tests in there against my database so
i'm doing sequel server unit test and
I'm doing my artifacts and if I pop back
to the summary of what's going on and
we'll look at that there were actually
results of that build that just ran and
we'll find it you know it took a few
seconds my test ran successfully I could
see you know the commits that are going
against it any warnings anything that
I've got going on in this case because
it looked at that next environment over
here on the right I see which
migrations weren't applied to my next
database yeah okay so that gives me an
integration place and in a matter of
fact you can see that there it knows
which stored procedure was changed there
right so it's kind of read through some
of the metadata I could see what's going
on and as a further step out of this
build I'm actually trigger to release as
well and where do you specify what
database it's going to is that part of
the build definition that is part of the
build definition so when I pop over here
that is a parameter visual studio like I
would add any other parameter and you'll
see here that I've said this build
integration database that's where I'm
gonna talk I next got it so that's
giving me kind of intermediate
environment nicely and if I pop over to
my visual studio let's sorry my
management studio let's grab this query
right here let's copy this and this is
my integration database okay okay so we
didn't touch this database you know I've
got a different coloring on it but my
row number five has been added
and my stored procedure here should run
cool right so cool right now as I've
done the process that I would normally
do a c-sharp and that I take my code
like everybody else's code put it
together generate an artifact and we can
then see if that is what we actually
want so you your continuous integration
there is actually a deployment as well
it is to another environment because in
the database world I I kind of need a
place to go look at that right so I've
actually moved this from one environment
to the neck so let me zoom in slightly
here I started right here in this
development area so this is where I made
the change and this is environment two
right here we just sent that change
okay and what I want to do then is of
course I've got QA yeah I've got this
staging and I've got production as well
okay so I want to kind of make sure my
code flows obviously testing at each
point in time run an application against
it having other developers QA people etc
look at what's going on right leading
businesspeople
I want to make sure that my code is
being deployed so let me grab let's
grab all this code real quick and let me
just look at my Qi environment all right
so if I run this now that stored
procedure doesn't exist
yep right neither does that Rover
because your bill definition only sent
it to the first database yeah my build
definition then actually kicked off this
release process as part of continuous
delivery so this release process says
once I built if I built successfully
mm-hmm and if I passed my tests whatever
is appropriate for myself what I'm going
to do is I'm going to do supply this
package out to a database and in this
case I'm sending it to my integration
environment oh so the build doesn't
actually do the deploying no no in this
case oh okay let me pop to the older
this new editors gotten slightly odd for
me but when I look at this build process
I'm sorry this release process this is
set as the option where they moved go
back to the first here click on one
phase one task that's where it is yeah
yeah so here I'm actually having this
kick off as per once the build a
successful okay it triggers this release
okay yeah so just like I want to do is I
want to have kind of an organized
process that makes sense
mm-hmm outside of the path in and the
parameters we could set this up in a
couple of minutes okay we would have to
go through the path you make sure we
haven't made anything incorrect there
but I have the ability to do that but
I've also got other release processes in
place in this case I've got a downstream
process as well which will push it to
those other environments okay so I have
the ability to make releases in a
consistent reliable fashion in a way
that as a DBA various times my career
have struggled with because as somebody
sends me a script I have to look at it
have to hope all the objects are
included mm-hmm
I have to hope that I've actually
remembered to correct connect to the
correct server right send it down there
right all the minutiae that just slows
down development right it just becomes
complexity just like deploying an
asp.net website or c-sharp too thick
client you know there I have to make
sure I go through all the process
correctly I have to remember that I need
to copy to these folders to these
servers mm-hmm right those things are
just they're kind of tedious things that
we don't want in general to do so having
this stuff happen automatically in a
lightweight process like visual studio
team services makes it really easy to
move this changes forward yep and see
what works and so this release is
created it's probably run by now because
usually they run fairly quickly and if I
come back over here and let's rerun this
code actually works this nice I've moved
it to QA yeah we could certainly repeat
that a forward to the other environments
as well right so cool trying to build
some of that DevOps process in here's
that I I make the process a definition
that is always handled in the same way
so we execute the same manner and then
if I find issues or if they find new
requirements I can slowly modify that
but I'm not dependent on a human to do
right and it gives you the ability to
not necessarily be the only one making
changes to the database just like in
coding you're not the only one coding
right right but things about the
continuous integration is I make changes
on my machine I run my tests everything
works you make changes on your machine
run your tests everything works marry
the code together the stuff doesn't work
anymore exactly right the CI will do
that I check in my code you check in
your code all the unit tests run we're
told immediately you can apply the same
process here I make changes the database
works on my machine you make changes
works on your machine and then you marry
them together and it all then goes
downstream and hopefully works right but
if hold of course and if it doesn't then
in process breaks but we now you know
why right so I've got a cool visual
studio team services gives me all
instrumentation to say what was deploy
what's included
so I don't have to dig through the
entire database I know in this case
there's two files that broke so if my
code doesn't work with your code yeah we
know which files I committed to go look
at and this isn't that hard to learn how
to do it's pretty easy to set up it is
pretty easy to set up yeah even even if
the UI changes it is I mean visual
studio team service I was amazed how
easy it is to actually do a build after
working in something like Jenkins which
works great but it's not the easiest
thing we work with yeah so visual stereo
team services and all the extensions
have made this a smooth process very
cool all right all right we learned
something you like migrations and
database development now I love it yeah
right well I love the fact that that you
can that DevOps and see ICD continuous
integration continuous deployment
pipelines are for databases too it's not
just for code right and you can just as
easily set one up for your database
stuff as you can for your code I love
that yeah yeah and I think that's one of
those things that will really help
improve the quality of our database
applications yeah oh absolutely cool so
that's part 1 part 1 part 2 part 2 we'll
do this again but we'll do it
innocent in a comparison method where
we're not going to try to track every
change right figure it out later
okay cool we'll see you next time on
visual studio toolbox
[Music]
Debugging Tips and Tricks Part 1
>> If your code is perfect and
there's nothing wrong with it,
don't watch this episode
of Visual Studio Toolbox
where Leslie Richardson will show
us debugger tips and tricks.
>> I envy that person.
[MUSIC]
>> Hi, welcome to
Visual Studio Toolbox.
So I'm your host
Robert Green and joining me
today is Leslie
Richardson. Hey, Leslie.
>> Hi.
>> Thanks for coming on the show.
>> Thanks for having me.
>> Leslie is a PM in
Visual Studio land.
>> Sure, I am.
>> We're going to talk about
debugging tips and tricks.
>> Yes, we are. So there's
obviously a lot to
cover in the debugging space
that sadly a lot of
people don't know about.
You can spend countless hours
debugging that one bug
and going through
the most tedious steps
possible when at the end of
the day you just want to get
back to writing code, right?
>> Yeah.
>> Yeah, so hopefully some
of these tips that I show
you will help you
out in the long-run.
>> Cool, and a lot of these have
been in the product for a while.
Some are new to 2019.
>> Yup.
>> So if you can remember
too when there's
something that's brand new and
2019, let's call that out.
>> Okay.
>> Otherwise, this is just
stuff in Visual Studio.
>> Awesome. Yeah, definitely.
So I'm going to be focusing more
on the .NET space today but
a lot of these features
overlap into C++ as well.
So I'm in Visual Studio
2019 right now
and I'm using an ASP.NET
Core application.
Because I loved to read so much,
this is an app that randomly gives
me a list of books that
I can choose to read and
add to my shelf or reject and
they won't be added to my shelf.
So this app also has a lot
of problems with it,
so hopefully we can use some of
the debugging tools available to
us in order to figure them out.
>> Cool.
>> So first off, I have
a breakpoint already set in
this Book Manager constructor
here and this happens
pretty early on in my program's
execution where it takes in
a JSON file containing a bunch
of different book-related
information,
converts each piece of that into
a book object and then stores
each of those in a list.
So I'm at the start
of my function here
but I actually want to navigate
to the bottom here instead.
So normally that
would be when I start
stemming F10 or step over in order
to get down there but that can
be tiresome especially because
I have this for loop
right in the middle,
so that can take a lot of
time and that's not
very productive of me.
So the other option
of course is to just
set a breakpoint at
the end and then hit F5.
But then if I do that,
I have to remember to delete
the breakpoint afterward.
>> Right, because
the next time you run
the app and you get up and go
for a coffee or something,
you come back and sitting on that
breakpoint you forgot to remove.
>> Exactly, it's like I
thought it was going to run
without me while I
get my coffee but no.
So another alternative is
something called Run to Click
which I can perform by
hovering over the line I
want to navigate to next.
When I do that, you'll notice there's
this little green glyph
icon that shows up,
and I can click on that and it'll
run all of my code up to
that particular line.
>> Which is easier
than going down there
right-clicking and
then finding Run to,
or set next statement,
or whatever it was.
This is just quicker.
>> Exactly. It's like having
a remote control for
your code and being
able to fast-forward to
where you want to go.
So from there, the reason
why I wanted to go
to the end of this function
is because I wanted to hone
in on that book lists which stores
a hundred different books
because I want
to quickly inspect each one.
When I hover over
it, I get a data tip
but one of my problems that I have
a data tips from time to time is
that the moment I hover away
from it, it disappears.
So if I want to keep
it for a while longer,
what I can do instead is pin it,
and when I pin it,
this data tip will stick around
for as long as I decided to leave
it until I ultimately close it.
>> You can drag that to
a second monitor; is that true?
>> You know I haven't actually tried.
Good question. I feel like
that should be possible.
>> Okay.
>> But good question. The good news
about this is that when I close
out of my debugging session here,
it'll still be present even
when I start a new one.
So now if I wanted to inspect
all of the contents
of this list here,
at first glance, this
isn't really helpful.
Let's say I wanted to inspect
each book by their names,
it would be a little
tedious to expand each
of these out until I find there's
the title property and
then keep going to
the next one and so forth
until I find what I'm needing.
So this also goes for if I were in
the Locals window as
well or Watch, or Autos.
Ideally, it would be
a lot nicer if instead of
getting the type of object
under the Value column,
I could see particular
properties that I'm
interested in so I can just
quickly skim through this list.
So thankfully, there is
a feature that you can
use in Visual Studio,
that's one of my favorites and
it's an attribute
called DebuggerDisplay.
That is an attribute
that allows you to
customize how you view
your objects in the Watch,
Autos, Locals, and Data Tip windows.
So to do that, I can go and
see where I defined my class.
At the top of that class definition,
I can write in
some DebuggerDisplay syntax.
The curly brackets
will return the value
of any property or properties
because I can go plural with it,
I can also use expressions,
if I wanted of whatever
property that I specify.
In this case, I want to view
books by their title property.
So I'm going to type in title,
and I'm also going to have to
restart the debugging session.
But hopefully, this is
where the magic happens.
So this is an attribute that
exists currently in F#,
C#, and Visual Basic.
So this is for manage users
but if you're a C++ user,
the equivalent that you
can use that performs
the same function is
something called Natvis
where the difference
mainly is that you have
to create a separate Natvis file
inside your project.
That contains some XML that
you can add to or modify in
order to perform the thing
that I'm about to show you.
So I need to go back to the end
of this function again.
I'm going to use Run To Click,
and I have my Data Tip that I penned
earlier that's still here
because I never closed it.
This is my favorite.
This is the magic.
>> That is cool.
>> So cool. I love it a lot.
>> Okay, now this is the
part where we have fun.
How long it's been in the process?
>> Yeah. Longer than 2015.
Longer than 2015. It's
been around for a while.
Longer than me, definitely.
>> That's my favorite
part of the show.
>> I get asked that all the time.
So is this a 2017, 2019 exclusive?
I'm like, "Oh no".
>> No. Awesome.
>> Yeah. So that's
one of my favorites.
So another thing that I like-
>> You can do
expressions, so you could
concatenate a couple
of fields, actually?
>> Exactly, yeah. If you wanted to do
some simple type of expressions,
then you can do that as well.
If you're interested in seeing
one property plus
another it's possible.
>> Could you do something
like a function that
says if these three
fields are missing,
just display "incomplete",
then if they're there,
display "complete". Can
you do stuff like that?
>> You can, yeah. You can do some
simple if conditional
type statements as well.
Do it at your own risk.
My recommendation for
when things start to
get very complicated in
your DebuggerDisplay syntax,
is to create another property
or function within
that class first called like
the DebuggerDisplay or
something like that.
Include all that logic and then you
can write the function name inside-
>> That makes a lot of sense.
>> -the DebuggerDisplay.
>> Okay.
>> From there,
another feature that I like
are the Text Visualizers
in Visual Studios.
So for instance, I have
this JSON variable here that
stores all my JSON contents,
and if I'm looking at it, first,
I need to actually
navigate back to it
because this is earlier on in
my code and I'm
currently out of scope.
So what I can use for
that is something
called set to .NET statement which
I think you mentioned earlier.
So to do that, I can pretend as
if I were doing another Run To Click,
so I can hold down
the Control key and that
green glyph will turn into
yellow icon which will
automatically move
my execution pointer up
to that particular line.
So that's nice especially if you want
to try out what different
execution paths are going to be
looking like or if you
want to go back and
re-inspect a previous variable
but you have to use it at
your own risk because
since you are changing
the execution flow in a way that
it is not necessarily intended,
it has the potential to mess
with the rest of your codes
execution unless you restart and
make a new debugging session.
So from there, I have the JSON
variable and looking at it,
it's not very readable right off
the bat because it's formatted
for JSON particular.
That and it cuts off the screen.
So if I'm looking at it in
the Local's window for instance,
there's this magnifying glass icon
that's next to that
and I can click this drop down
to get a list of
different visualizers I can use.
So I'm going to use the JSON
visualizer because it's a JSON.
This time I get a lot
better of a formatted view.
So I can quickly view
this giant string and it's
proper format which is great.
Again, if you had a string
that's cater for HTML or XML,
then you can do that
as well or if you
have something that's catered for
something completely different,
you can also make
your own visualizers,
so that's pretty needed.
Also, if you just have
a giant paragraph of text
being stored in a variable,
you can just use the regular
text visualizer as well.
>> Cool.
>> So from there, now I
want to start looking
into some problems with
my application itself.
So I'm going to hit "Continue",
and so this is the general
application, and again,
I can go to
this rate books page where'll
randomly give me a list of
books that I can read to add
in my shelf or not read
and they won't be added.
So in my case, I just want to read
everything. So I'm going to add.
>> A hundred books.
>> Yeah, I'm going to
read all hundred of them.
>> How long will that take you?
>> It depends. Depends
on how big it is.
I have the goal every
year of reading 25 books.
So I'm not quite at
the 100 a year things,
so let's go with four years for 100.
But I'm noticing that
of the 100 books that
are supposed to be added to
the shelf when I do that,
it looks like there's
only around half of them.
So if I go into Visual Studio,
I want to double-check that
out but also I should receive
a notification if I click on
the "Rate Books" page telling
that all the books are gone.
Instead, I get a lovely
exception error instead.
So let's try to solve this issue.
I'm going to navigate to my
AddAlltoShell() function,
and this is my function
that will take each book on
the "Rate Books" page and
move them into my shelf.
I'm thinking the problem lies
within this for loop here.
So I want to see
what's going on here.
When I first started coding,
I was really big on
print statements everywhere.
Yeah, I don't know how many people
in the audience out there
love print statements as much
as I did but they're great.
>> Well, I graduated to
writing things to a text file.
>> Yeah, that's great
too, accounts logging.
But I guess the problem with
that at least for me was that it
would be all over my code
even when it's not needed,
I forget to delete it when I'm done.
So I prefer to not
modify my code nowadays.
If you do like to log your
information to the output window,
an alternative you can
use is a trace-point
which is an offshoot of
a regular breakpoint.
That will allow me to
essentially perform
a print statement without having
to modify my code in the process.
I'm going to set a normal breakpoint
inside this for loop first
and then I can hover over
the breakpoint to get
little settings icon.
When I click on that
I'm going to select
"Actions" and here I'll get a prompt
telling me what I want to
log to the output window.
In this case, I want to see
how many indices this for loop
goes there before it stops because
I feel like it's
stopping prematurely.
So I'm going to do index:{i} and
return the value of variable i.
Hit "Enter" and I'm
going to leave "Continue
Execution" checked but
if you wanted your code
to stop when a trace-point
is about to be printed,
you can do that as well.
You get a diamond icon instead
of the circle as well.
I'm going to boot up
the program again.
>> It would come in handy if you
wanted to watch
the progress of something.
I was working on some code yesterday
that looks in GitHub repositories
and it loops through
a large number of them and some of
them there was an exception
and I just wanted to
know which ones through
the exception without
watching this program go,
that could take hours.
So I wrote it to a file
which worked but
it seems like this way
I could just write
that information out to
the console window and then
I don't have this printing,
the saving to a file in my code,
which I could
accidentally released to
production and then it will
blow up because someone
didn't have the directory that
this is writing to, right?
>> Right.
>> The big risks in
modifying the code to do
debugging is you leave
that stuff in there.
>> Yeah, because I am
pretty sure I've done
a demo in school at
one point where I left
some arbitrary console.log
something rather,
and I always write weird quotes
in it when I'm frustrated
and trying to debug.
So like I said, like a random
[inaudible] right in
the middle of the demo.
>> What idiot wrote this code,
how comes this doesn't work?
>> From here, I'm going to perform
that same "Add All Books" to
My Shelf option and this time,
I should see some print
statements to go with it.
So going back into VS, I can go to
the output window and scroll up a
little bit and here you'll notice
that there's a bunch of
related print statements going
back with the trace-point
that I created.
This is one way to check out
your trace-points but also
the problem with this is that
these can easily get buried
in the sea of stuff
in the output window.
So the other place where you
can check them out that I
like is in the
diagnostic tools window.
This is the window that
I have a bad habit of
closing usually when I'm
debugging but one of
the perks of keeping it
open is this because you
can filter out events that you see.
>> I have a bad habit of leaving it
open and watching the pretty picture.
>> Yes, that's true too.
I do love the CPU graphs.
>> Yeah, but then what
are you doing with that?
>> But it makes you
look official when
somebody's walking past you,
what is that person doing?
>> Although I did use it in
this application I was working on
to tell if there was a problem
because the exceptions,
and there's like 10 exceptions
that just happen,
but then when I noticed
that there were 20,000
exceptions or 50,000
or 150,000 exceptions,
that was my clue
because the way this code
works if it hits an exception,
it just sits in a loop because
it's assuming that it
just needs to keep
trying and when I got to 400,000
exceptions that was my clue that,
hold on a second.
>> Like well, okay, maybe
I should do something.
You can view your
trace-points here as well
which might make things
a little easier too.
So from there, I'm noticing
that my index value,
i, only goes up to 49 when
it should go up to 99.
At this point, I just want
to step through like that
last iteration of my for loop just
to see what's going on
with each piece of it.
I'm going to go back to
where I set this trace-point
and now the new problem
is I want to go through
this for loop but I don't
want to start from
the very beginning of it,
like from when i is equal to zero
because I'll be there for
days and chances are I'm
not going to pay attention
and I'm going to skip when
i equals 49 and then I
have to rinse and repeat.
So I can use a conditional breakpoint
instead which will allow me to
halt my code only under
a specific scenario that I give it.
So where I set the trace-point,
I'm going to go back to settings
and I'm going to uncheck
"Actions" because I'm done with
this tracepoint and
check "Conditions".
From there, I want my code to
halt when i is equal to 49,
hit "Enter" and closeout.
The conditional breakpoint
has been created based off of
this little plus icon
inside the standard icon.
I'm going to have to
restart it again.
>> Now, those conditional breakpoints
are things have been in there for
pretty much all or I don't even
remember when those were created.
>> Yeah, I have no idea. I feel like
I started hearing about Visual Studio
around 2013 or whichever one
was before 2015.
>> 2013.
>> Yeah, '13.
So anything past
that, I have no idea.
Cool. Again, we're performing
that "Add All Books"
to My Shelf action.
My code halts this
time and you'll notice
that the value of i is set
to 49 instead of zero.
So from there if I step
through this for loop,
I'm noticing that I used my
neutralBooks.Count here as my loop
condition and at the same time,
a book is being removed from
neutralBooks at the end
of each iteration,
which is causing the count to
decrease at the start
of each new iteration.
So think I found the problem here.
So I'm going to stop debugging
and we're going to comment
out this line and then just clear
all the books at
the very end of the function
instead and that should solve
the issue, get rid of that.
>> Now, is there a way,
okay, let's say you thought
that was the issue,
you could add neutralBooks.Count
to the watch window, right?
>> Right.
>> But, correct me if I'm
wrong, but it doesn't update in
real-time as the application
is running; is that true?
>> Oh, it does update in real-time.
If you add it to the watch window
and you're stepping
then if it changes,
it will let you know that it changed
because it usually highlights in red
in either the watch
or in local's window.
>> All right. Good.
>> Cool. From there,
adding all books.
It's time it looks like there's
a lot more books that have been
added and just to double-check,
it turns out yeah,
I've rated all the books
in the library already.
That was conditional breakpoints
and tracepoints,
two awesome alternatives to
regular breakpoints that you can use
in your everyday
debugging environment.
>> Cool. So I think what
we'll do is stop here
and call this part one
and then next week
we'll do part two and see
more debugging tricks.
People want to learn more about that,
you wrote a blog post on this, right?
>> I did.
>> People can check out at
aka.ms/DebuggerDisplay.
>> Yeah, it goes through a lot more
of the different scenarios that you
can use with it and you can go
check it out for more examples.
>> We will see you next time
on Visual Studio Toolbox.
[MUSIC]
