| Topic | Presenter | Summary | Duration | Tags | Quiz | Captions |
| ------------ | ------------- | ------------------------------------------------------------------------------------------------------------- | -------- | ----------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | -------- |
| ASP.Net CH 4 | Chris Reddick | Chapter 4 of the ASP.Net Core 3 and Angular 9 book is discussed in this dev training session from 07/31/2020. | 51:05 | #DevTraining, #ClarityDevelopers, #FridayTrainings, #ASP.NetBook, #ASP.NetCore3, #Angular | ASP.Net Book, CH 4 | |00:00:06.584 --> 00:00:10.172 - want the whole team to be able to contribute to the E Commerce 00:00:10.172 --> 00:00:11.276 - platform and the connector 00:00:11.276 --> 00:00:13.464 - platform. Both of those are 00:00:13.464 --> 00:00:18.309 - expected to be. Opportunities for you guys too as you see fit 00:00:18.309 --> 00:00:23.132 - and as you kind of grow an interest or just as you're just 00:00:23.132 --> 00:00:26.842 - interacting with those products. If you see something that's you 00:00:26.842 --> 00:00:30.923 - know could be improved on, we really welcome you putting the 00:00:30.923 --> 00:00:35.004 - time into it, certainly. Please feel free to review and get 00:00:35.004 --> 00:00:38.343 - approval first with the project management team member, but 00:00:38.343 --> 00:00:40.569 - clarity itself will pay for the 00:00:40.569 --> 00:00:46.143 - time. In most of the cases were needed, uhm, to do the work to 00:00:46.143 --> 00:00:51.057 - make it better and make it right instead of just having it be not 00:00:51.057 --> 00:00:55.320 - great. So I'm really excited for Jesse to share, 'cause that's 00:00:55.320 --> 00:00:59.402 - kind of what he saw. I saw something that was hard coded an 00:00:59.402 --> 00:01:03.798 - and how to make it more dynamic. I think that you know there are 00:01:03.798 --> 00:01:07.566 - opportunities to improve it even more, but this was a really nice 00:01:07.566 --> 00:01:10.392 - little enhancement that will immediately help the client that 00:01:10.392 --> 00:01:13.846 - he was working on, but then also benefit the core platform. 00:01:14.420 --> 00:01:17.533 - So kudos on that and looking forward to that. And then 00:01:17.533 --> 00:01:19.797 - we're also going to go over database migrations. 00:01:21.350 --> 00:01:24.639 - This this is particularly interesting, I think to a lot of 00:01:24.639 --> 00:01:28.227 - front end team members, but it might actually help some of the 00:01:28.227 --> 00:01:31.217 - back end team members in and basically it's just talking 00:01:31.217 --> 00:01:34.506 - about issues that can occur when running a database migration, an 00:01:34.506 --> 00:01:37.496 - entity framework and ultimately you know how to prevent those 00:01:37.496 --> 00:01:41.084 - and kind of keep yourself from running into it. And then you 00:01:41.084 --> 00:01:44.373 - know if and when you do, and inevitably inevitably you will. 00:01:44.373 --> 00:01:47.961 - How to work through those. Some of the techniques and you know, 00:01:47.961 --> 00:01:52.147 - kind of how to identify what the issue is and then how to work 00:01:52.147 --> 00:01:53.950 - through this. So. 00:01:54.760 --> 00:01:56.028 - All that makes sense. 00:01:57.800 --> 00:02:01.112 - I think we can get started on this and will just kind 00:02:01.112 --> 00:02:01.940 - of start with. 00:02:03.630 --> 00:02:06.138 - Chapter four of the book, and 00:02:06.138 --> 00:02:11.152 - um. Let me see if I can pull the book open here and we can 00:02:11.152 --> 00:02:14.904 - get started on that. So one of the things that we can do and 00:02:14.904 --> 00:02:18.120 - that you know is is part of this one is just getting 00:02:18.120 --> 00:02:19.192 - everything set up here. 00:02:21.130 --> 00:02:25.018 - And I'm pulling the table of contents and then I'll show my 00:02:25.018 --> 00:02:28.582 - screen. So this one goes over this one goes over entity 00:02:28.582 --> 00:02:32.146 - framework an I think it'll be a pretty interesting topic. I 00:02:32.146 --> 00:02:36.034 - think most of the back end team is pretty familiar with entity 00:02:36.034 --> 00:02:39.598 - framework. Uhm, OK, there we go, you guys see that OK? 00:02:40.400 --> 00:02:45.548 - OK, so um, this is pretty interesting. Um, if you're not 00:02:45.548 --> 00:02:51.164 - aware of it already, that you know we use entity framework for 00:02:51.164 --> 00:02:56.780 - our existing E Commerce platform and really just in general as a 00:02:56.780 --> 00:03:01.460 - standard when we're working with OMS or object relational mapper 00:03:01.460 --> 00:03:06.608 - and basically the core idea behind an O RM is essentially 00:03:06.608 --> 00:03:12.050 - too. Make it much easier an an kind of standardize the 00:03:12.050 --> 00:03:16.270 - experience in the process and really the quality and the 00:03:16.270 --> 00:03:20.068 - Fidelity of working with the database previously when working 00:03:20.068 --> 00:03:25.554 - with the database. Kind of prior to our EMS you would end up 00:03:25.554 --> 00:03:28.508 - physically in many cases physically separating out. 00:03:29.170 --> 00:03:32.250 - The Database Administration from the software development. 00:03:32.860 --> 00:03:36.994 - And this is really where the DBA role has has been a significant 00:03:36.994 --> 00:03:40.492 - role with a lot of software development and really still is. 00:03:40.492 --> 00:03:44.626 - I mean, there's still a lot of applicability to the DBA type of 00:03:44.626 --> 00:03:49.740 - role. Um, however, is pretty interesting because a lot of the 00:03:49.740 --> 00:03:51.630 - that space is kind of. 00:03:53.070 --> 00:03:57.930 - Gotten sucked into the commoditization of a lot of the 00:03:57.930 --> 00:04:02.790 - basic pieces of interacting with the database into this object. 00:04:02.790 --> 00:04:04.248 - Relational mapper concept. 00:04:05.260 --> 00:04:08.476 - And essentially what we're doing in this particular 00:04:08.476 --> 00:04:12.496 - example is we're going in and we're actually, you know, 00:04:12.496 --> 00:04:16.114 - building out with entity framework kind of building out 00:04:16.114 --> 00:04:20.134 - the data source an going through this in detail and 00:04:20.134 --> 00:04:24.154 - getting it all set up. And then of course actually 00:04:24.154 --> 00:04:26.968 - accessing the data, interacting with the database. 00:04:28.830 --> 00:04:32.790 - So one of the things that I realized whenever I first 00:04:32.790 --> 00:04:36.030 - started software development as a full-time karere which was 00:04:36.030 --> 00:04:39.630 - about 14 years ago. Um, it was really interesting because. 00:04:40.580 --> 00:04:45.079 - A Chad Perry, who started clarity with me, um, he he 00:04:45.079 --> 00:04:49.987 - basically had me go write a bunch of classes, um, to access 00:04:49.987 --> 00:04:55.304 - the data layer. And for those of you who haven't done this, you 00:04:55.304 --> 00:04:59.803 - know for that long or haven't seen the structure that was 00:04:59.803 --> 00:05:04.302 - pretty common. There's an idea of this three tier kind of 00:05:04.302 --> 00:05:07.983 - software model where you basically have the data layer, 00:05:07.983 --> 00:05:10.437 - the business layer in the UI. 00:05:11.250 --> 00:05:16.038 - And So what I was doing was I was building out this kind of 00:05:16.038 --> 00:05:19.800 - data layer and within the code the data layer. The intention 00:05:19.800 --> 00:05:23.562 - behind that is to make it so that whenever your business 00:05:23.562 --> 00:05:26.982 - layer kind of talks to the database and gets information 00:05:26.982 --> 00:05:29.376 - from the data layer of the code. 00:05:30.250 --> 00:05:34.180 - It's a physically separated layer that isn't that. You know, 00:05:34.180 --> 00:05:38.503 - the UI doesn't directly interact with the UI layer, doesn't talk 00:05:38.503 --> 00:05:40.075 - to the data layer. 00:05:41.020 --> 00:05:45.496 - And therefore, if you ever need to change your database model or 00:05:45.496 --> 00:05:49.226 - your type of data storage data persistence that you're using, 00:05:49.226 --> 00:05:51.464 - then you kind of have this. 00:05:52.860 --> 00:05:56.900 - Essentially, dependency that that is only on that data model 00:05:56.900 --> 00:06:01.344 - layer, and so you can change one layer of your code. 00:06:02.040 --> 00:06:05.144 - Change the data database persistence model that you're 00:06:05.144 --> 00:06:10.188 - working with and it just works, and so that was really kind of 00:06:10.188 --> 00:06:15.232 - the idea and so back in the day before really, oh RM's existed. 00:06:15.232 --> 00:06:19.888 - You would physically go right. All of the code for this data 00:06:19.888 --> 00:06:24.156 - layer, an it was pretty cumbersome. And there was a lot 00:06:24.156 --> 00:06:28.424 - of just user error with. I remember the number one reason 00:06:28.424 --> 00:06:33.468 - that we would run into bugs was when we were typing those things 00:06:33.468 --> 00:06:37.814 - out. And building out these classes that were essentially 00:06:37.814 --> 00:06:39.446 - representing tables in the 00:06:39.446 --> 00:06:44.220 - database. There were issues with naming and just following a 00:06:44.220 --> 00:06:48.440 - pattern. Believe it or not, and I I mean I think you guys can 00:06:48.440 --> 00:06:51.080 - relate to this with some of the software development that you're 00:06:51.080 --> 00:06:54.940 - doing. I mean, in my experience, in many of my issue. 00:06:56.240 --> 00:07:01.115 - OK, just holler if you guys would just like you just did. If 00:07:01.115 --> 00:07:05.990 - it cuts out but the the Long story short is that, oh, RM's 00:07:05.990 --> 00:07:10.865 - kind of came into the picture. An really changed a lot of this. 00:07:10.865 --> 00:07:14.990 - An entity framework was not really the first, or it really 00:07:14.990 --> 00:07:19.490 - kind of came after a lot of the industry was doing OMS. 00:07:20.980 --> 00:07:24.808 - And the whole idea behind an object relational mapper is that 00:07:24.808 --> 00:07:28.636 - as it started, you would build your database and instead of 00:07:28.636 --> 00:07:32.464 - building a database, an writing sequel to talk to that database, 00:07:32.464 --> 00:07:36.640 - which is the other big piece that we would do. We would 00:07:36.640 --> 00:07:40.120 - literally right these class files and then we would write 00:07:40.120 --> 00:07:44.502 - stored procedures. And if you guys haven't done a lot of 00:07:44.502 --> 00:07:48.506 - stored procedures, I know some of you have done a ton of them. 00:07:48.506 --> 00:07:52.510 - For those of you who haven't, it's, uh, it's it's own area to 00:07:52.510 --> 00:07:55.590 - completely optimize. It's really its own area of specialty, isn't 00:07:55.590 --> 00:07:59.594 - it? For those of you guys that are familiar with it and you 00:07:59.594 --> 00:08:03.598 - really have just like with C Sharp, you have a lot of depth 00:08:03.598 --> 00:08:07.294 - to it. And kind of endless knowledge that you can kind of 00:08:07.294 --> 00:08:11.696 - pursue. And so you know, relatively speaking, and so 00:08:11.696 --> 00:08:16.228 - anyway, Long story short, there is a lot of commoditization of 00:08:16.228 --> 00:08:20.760 - that for simpler applications. An in that kind of grew into 00:08:20.760 --> 00:08:25.704 - this kind of medium level of applications and then even a lot 00:08:25.704 --> 00:08:29.412 - of enterprise applications they could leverage and ORM instead 00:08:29.412 --> 00:08:34.356 - of having a DBA having to go in and physically right stored 00:08:34.356 --> 00:08:38.064 - procedures and physically right. A lot of the classes. 00:08:38.620 --> 00:08:42.767 - You could kind of have that the auto generated to some 00:08:42.767 --> 00:08:47.710 - significant extent. And so this kind of had it's kind of Genesis 00:08:47.710 --> 00:08:50.851 - before entity framework came around, and then any framework 00:08:50.851 --> 00:08:53.992 - essentially was a Microsoft offering. I always joke around 00:08:53.992 --> 00:08:57.831 - about some of what Microsoft does. They kind of see what's 00:08:57.831 --> 00:09:02.019 - working and then they just gobble up all the good ideas and 00:09:02.019 --> 00:09:05.858 - then standardize it and then boom, they deliver it as an 00:09:05.858 --> 00:09:09.348 - option. You know, a few years after the bleeding edge 00:09:09.348 --> 00:09:10.395 - solutions come out. 00:09:11.020 --> 00:09:16.025 - Uh, which I think is great. You know, for most of the industry, 00:09:16.025 --> 00:09:19.490 - for those guys that built something you know that 00:09:19.490 --> 00:09:22.570 - delivered a solution. Before Microsoft had one, they 00:09:22.570 --> 00:09:26.805 - basically got crushed out of that space, so really sucks for 00:09:26.805 --> 00:09:30.655 - them. But you know, that's business so, but you know 00:09:30.655 --> 00:09:34.120 - ultimately, the interesting thing about any framework is it 00:09:34.120 --> 00:09:38.740 - was really bad at 1st. And frankly it still has some major 00:09:38.740 --> 00:09:40.280 - issues whenever using entity 00:09:40.280 --> 00:09:44.378 - framework. And let me let me just go ahead and pull up 00:09:44.378 --> 00:09:47.546 - some of the code here and I'm going to switch screens. 00:09:49.060 --> 00:09:52.672 - Maybe if you do have it open, feel free to take over and show 00:09:52.672 --> 00:09:54.220 - the code. I'm just waiting for 00:09:54.220 --> 00:09:58.326 - my computer respond. And this, while we're kind of waiting for 00:09:58.326 --> 00:10:00.036 - that to happen, um, basically. 00:10:00.120 --> 00:10:05.208 - The idea behind any framework is it it kind of offers several 00:10:05.208 --> 00:10:10.296 - different approaches an most if not if not like almost all uses 00:10:10.296 --> 00:10:14.112 - of entity framework now tend to be code first. 00:10:14.810 --> 00:10:18.286 - But originally the way that it worked was it was essentially 00:10:18.286 --> 00:10:21.762 - database 1st and all kind of explain what those two are. 00:10:23.400 --> 00:10:28.250 - Essentially, the idea kind of originally was you build your 00:10:28.250 --> 00:10:33.585 - database out and you build your database structure and then you 00:10:33.585 --> 00:10:36.495 - tell entity framework to go look 00:10:36.495 --> 00:10:41.638 - at it. And it it then looks at the structure. 00:10:42.330 --> 00:10:47.730 - And it looks at how everything is configured. Uhm, and then it 00:10:47.730 --> 00:10:52.230 - it kind of builds your data model for you significantly. 00:10:53.280 --> 00:10:57.245 - And for those of you who are very detailed on this, it's just 00:10:57.245 --> 00:11:00.600 - not literally building your data model, but it builds your data 00:11:00.600 --> 00:11:03.955 - access layer if you will, and kind of allows you to. 00:11:06.340 --> 00:11:08.340 - Represent the database in code. 00:11:09.260 --> 00:11:11.960 - And so OK. So I think my everything is responding 00:11:11.960 --> 00:11:14.930 - again, so it should be just a second and I'll show. 00:11:16.140 --> 00:11:16.740 - OK. 00:11:23.080 --> 00:11:27.435 - OK, so you guys can see my screen now. I think with the 00:11:27.435 --> 00:11:31.455 - code showing. Yeah, um so this is this is pretty interesting. I 00:11:31.455 --> 00:11:35.140 - mean this is a really simple code code. First example here. 00:11:36.670 --> 00:11:41.411 - But as I was saying with the database first approach you 00:11:41.411 --> 00:11:45.290 - would literally go build your database with with your 00:11:45.290 --> 00:11:48.307 - tables and then entity framework would actually. 00:11:49.860 --> 00:11:51.468 - Build a uhm. 00:11:52.430 --> 00:11:55.830 - Essentially a representation of that database in code for you 00:11:55.830 --> 00:11:59.570 - and believe it or not, it actually used the same core 00:11:59.570 --> 00:12:04.330 - model. Is is what we use with our T fours. So whenever we see 00:12:04.330 --> 00:12:06.710 - these T Fours in the E Commerce 00:12:06.710 --> 00:12:12.690 - platform. That's really how a lot of the OMS, even before 00:12:12.690 --> 00:12:17.580 - entity framework used to do things. And there's some pretty 00:12:17.580 --> 00:12:21.981 - interesting applications that you can literally point at a 00:12:21.981 --> 00:12:25.798 - database. And they'll build out an entire 00:12:25.798 --> 00:12:26.644 - administrative interface. 00:12:28.190 --> 00:12:32.667 - Dynamically based on the tables in the fields that you have 00:12:32.667 --> 00:12:37.144 - there. So just imagine trying to write an entire application by 00:12:37.144 --> 00:12:38.772 - hand to go update. 00:12:39.670 --> 00:12:43.387 - Delete create new records, search. Have a grid listing 00:12:43.387 --> 00:12:47.930 - all of that for say 150 tables. I mean, that's just 00:12:47.930 --> 00:12:49.995 - insane. To do that manually. 00:12:51.580 --> 00:12:56.026 - And that's really where a lot of these are. EMS came in. You 00:12:56.026 --> 00:12:59.446 - could literally attach them to your database and they would 00:12:59.446 --> 00:13:03.208 - spit out code that would do these core functions of crud 00:13:03.208 --> 00:13:04.576 - create, restore, update, delete. 00:13:05.820 --> 00:13:10.561 - And so it's really powerful model. UM, in general, uh, that. 00:13:11.190 --> 00:13:15.623 - Can have evolved from being database first to being a what's 00:13:15.623 --> 00:13:20.056 - called code first an essentially the idea behind code. First is 00:13:20.056 --> 00:13:23.683 - that whenever you're building a database and you're making 00:13:23.683 --> 00:13:28.922 - changes to it and a lot, you guys see this all the time. 00:13:28.922 --> 00:13:33.355 - Whenever you make a change to the database, I think this 00:13:33.355 --> 00:13:35.370 - happens a lot with DNN. 00:13:36.950 --> 00:13:41.752 - It's hard to track that I know for a lot of the team members 00:13:41.752 --> 00:13:45.525 - that are doing DNN projects and there are changes to modules 00:13:45.525 --> 00:13:49.298 - like a module gets installed. It can break your DNN instance 00:13:49.298 --> 00:13:53.071 - locally if you're pointed at the same DNN instance that somebody 00:13:53.071 --> 00:13:57.873 - else is working on, which is why we tend to say, you know, bring 00:13:57.873 --> 00:13:58.902 - your databases locally. 00:14:00.540 --> 00:14:02.502 - But if you somebody installs a 00:14:02.502 --> 00:14:06.465 - module and. Someone else in the team doesn't have that module. 00:14:06.465 --> 00:14:09.710 - You've made a change to the database and now other people 00:14:09.710 --> 00:14:10.890 - can't, really, you know. 00:14:11.550 --> 00:14:14.871 - Uh, work with that the application anymore because the 00:14:14.871 --> 00:14:19.299 - application is seeing a change to the database and so that kind 00:14:19.299 --> 00:14:23.727 - of evolved from this database 1st and you look at the database 00:14:23.727 --> 00:14:28.155 - as you're kind of source of truth for what your data model 00:14:28.155 --> 00:14:32.214 - is to. OK, we use source control, it's really clumsy and 00:14:32.214 --> 00:14:35.904 - challenging to manage a database in source control. There are 00:14:35.904 --> 00:14:40.332 - companies that have done it. If you guys have seen our redgate 00:14:40.332 --> 00:14:41.439 - tools there really. 00:14:41.540 --> 00:14:45.460 - Awesome, an really powerful and they actually figured out a 00:14:45.460 --> 00:14:48.988 - really nice model for doing source control for databases, 00:14:48.988 --> 00:14:54.084 - which is pretty awesome, but I mean I just don't know that many 00:14:54.084 --> 00:14:58.788 - companies that actually use that and so it evolved from that to 00:14:58.788 --> 00:15:03.492 - being code first and so code first is literally code that is 00:15:03.492 --> 00:15:06.236 - essentially representing the database and then executing 00:15:06.236 --> 00:15:08.980 - commands whenever the application starts up whenever 00:15:08.980 --> 00:15:14.076 - it runs and going and seeing if the data model matches the code 00:15:14.076 --> 00:15:18.889 - first. And if it doesn't, then it runs a migration to get it to 00:15:18.889 --> 00:15:22.222 - match the code first, and so your code first code defines 00:15:22.222 --> 00:15:24.040 - what your data models look like. 00:15:24.970 --> 00:15:30.955 - Anne, it's essentially it's very similar to T SQL. 00:15:31.560 --> 00:15:35.707 - Where you would have your, you know your definition of your 00:15:35.707 --> 00:15:39.477 - table structure, which you can see here we have city. 00:15:40.230 --> 00:15:44.344 - Uhm, and then we have a country for this particular case. 00:15:45.220 --> 00:15:49.680 - And we're essentially using just kind of a very vanilla. 00:15:50.270 --> 00:15:52.556 - Uhm, you know code first model. 00:15:54.120 --> 00:15:58.113 - Anne were telling it that whenever it's time to, uh, go 00:15:58.113 --> 00:15:59.202 - create the model. 00:15:59.830 --> 00:16:04.462 - Uh, that we need these two entities to be in in the 00:16:04.462 --> 00:16:09.070 - database. And if they're not, it's going to go build them. 00:16:09.070 --> 00:16:11.934 - And then, um, we're defining what they are. 00:16:13.080 --> 00:16:17.610 - So just like you guys you know if you if you go look at a 00:16:17.610 --> 00:16:18.818 - standard database table and. 00:16:19.500 --> 00:16:21.840 - Kind of compare, uhm? 00:16:22.850 --> 00:16:25.910 - You know, with any a database table, let me 00:16:25.910 --> 00:16:27.610 - actually get a better one. 00:16:28.740 --> 00:16:29.180 - Hum. 00:16:31.470 --> 00:16:35.838 - Should work with any database table you know you kind of have 00:16:35.838 --> 00:16:39.842 - your columns an you typically you're going to have a primary 00:16:39.842 --> 00:16:43.482 - key and you may have some foreign keys. That's literally 00:16:43.482 --> 00:16:46.758 - what we're doing here where we're essentially designing out 00:16:46.758 --> 00:16:50.034 - our table structure, and so we're naming the table. 00:16:50.620 --> 00:16:55.664 - Uh, this table is called City and this is the primary key ID 00:16:55.664 --> 00:17:00.320 - and you can see we have these. You know these little attributes 00:17:00.320 --> 00:17:04.588 - at the top of the data type or the data fields. 00:17:05.200 --> 00:17:10.372 - And so this is basically how you do code. First you essentially 00:17:10.372 --> 00:17:12.527 - build out your class that. 00:17:13.410 --> 00:17:17.814 - Defines the name of the table and then includes all of the 00:17:17.814 --> 00:17:22.290 - fields. And there's there's some nuance that will go over here. 00:17:22.290 --> 00:17:25.750 - Uh, with how you actually use these attributes to accomplish 00:17:25.750 --> 00:17:29.556 - certain things. And as we go into the next few chapters, 00:17:29.556 --> 00:17:31.286 - you'll actually see even more 00:17:31.286 --> 00:17:36.803 - detail. Um? On you know, kind of handling some of the 00:17:36.803 --> 00:17:41.087 - nuances of this, but you can see that we have a foreign 00:17:41.087 --> 00:17:44.657 - key constraint with the country ID, so we have data 00:17:44.657 --> 00:17:48.584 - type of int, an country ID and this is relating this 00:17:48.584 --> 00:17:51.083 - particular country ID field to the country. 00:17:53.130 --> 00:17:57.120 - And you can also see that. I mean, I, I think you guys just 00:17:57.120 --> 00:18:00.825 - looking at this can kind of get the idea that we have data 00:18:00.825 --> 00:18:01.965 - type and field name. 00:18:03.350 --> 00:18:06.878 - These attributes or self descriptive so this is a 00:18:06.878 --> 00:18:11.582 - primary key and then this is required and in in a SQL 00:18:11.582 --> 00:18:15.502 - database you typically have this concept of whether or not 00:18:15.502 --> 00:18:20.206 - a field is required and so this is all kind of correlate 00:18:20.206 --> 00:18:24.910 - Stew. This designer or writing T SQL to design out a database 00:18:24.910 --> 00:18:26.870 - table. So this allow nulls. 00:18:28.480 --> 00:18:31.966 - Being unchecked correlate Stew the required attribute. 00:18:32.590 --> 00:18:37.658 - And then you just kind of go down the list and you can see 00:18:37.658 --> 00:18:41.640 - that most of these are just simple strings and then you 00:18:41.640 --> 00:18:44.898 - can do your foreign keys with this navigation properties 00:18:44.898 --> 00:18:47.432 - concept where we're linking to another table. 00:18:48.920 --> 00:18:52.760 - And then we're basically specifying what the foreign 00:18:52.760 --> 00:18:59.000 - key value is here. So this is using the country ID field in 00:18:59.000 --> 00:19:03.320 - the city table to relate to the country entity. 00:19:05.330 --> 00:19:09.698 - And then the only other thing that that we're doing in this 00:19:09.698 --> 00:19:13.702 - chapter. That's interesting, I think, is just this idea of the 00:19:13.702 --> 00:19:17.706 - being able to specify not just decimal data type, but actually 00:19:17.706 --> 00:19:22.074 - gives more Fidelity on it. So put the decimal placement in the 00:19:22.074 --> 00:19:26.078 - correct location for this usage. So we're doing for for places 00:19:26.078 --> 00:19:29.354 - after the decimal, for precision for the lat long. 00:19:29.980 --> 00:19:36.508 - So, so once you actually put put everything into place, then you 00:19:36.508 --> 00:19:38.684 - essentially create a database 00:19:38.684 --> 00:19:42.442 - migration. And in this particular example, the 00:19:42.442 --> 00:19:47.928 - migration isn't going to be here when you start, and then you run 00:19:47.928 --> 00:19:50.360 - a command. Um? 00:19:51.150 --> 00:19:58.040 - To actually generate a database migration, so you're going to 00:19:58.040 --> 00:20:00.107 - have an initial. 00:20:01.130 --> 00:20:05.156 - Database migration, which you can see here, and so anytime you 00:20:05.156 --> 00:20:09.914 - go and make changes to these classes and add to them or or 00:20:09.914 --> 00:20:13.208 - removed from them, modify, etc. You run a migration. 00:20:14.020 --> 00:20:19.900 - And so this is kind of the core of, you know, the. I mean 00:20:19.900 --> 00:20:24.100 - significantly the value of the code first model versus the 00:20:24.100 --> 00:20:28.300 - database 1st. And there's again. There's always more nuanced and 00:20:28.300 --> 00:20:32.920 - more depth to it, but this is really, really powerful, because 00:20:32.920 --> 00:20:37.120 - any changes that are happening to the database were actually 00:20:37.120 --> 00:20:41.740 - capturing that encode. And this goes into source control. And so 00:20:41.740 --> 00:20:44.260 - this essentially enforces consistency and Fidelity 00:20:44.260 --> 00:20:48.186 - between. Developers an you know across deployments an it it's 00:20:48.186 --> 00:20:51.642 - it's kind of bringing everything into this kind of 00:20:51.642 --> 00:20:55.866 - source of truth, which is the code that's checked into source 00:20:55.866 --> 00:21:00.474 - control, and so this is just taking all of that. You know 00:21:00.474 --> 00:21:05.082 - all of that actual code and representing it in a way that 00:21:05.082 --> 00:21:07.386 - it's going to get generated into. 00:21:09.590 --> 00:21:10.709 - Uh, into SQL. 00:21:11.430 --> 00:21:16.105 - And if you're not familiar with this, uhm, entity framework, you 00:21:16.105 --> 00:21:20.355 - can actually within SQL Server Management Studio. You can turn 00:21:20.355 --> 00:21:21.630 - on a profiler. 00:21:23.160 --> 00:21:27.246 - That they are profiler. Yeah, that that literally will 00:21:27.246 --> 00:21:31.786 - watch the commands that are going across sequel and this 00:21:31.786 --> 00:21:35.872 - is actually pretty helpful for debugging if you ever 00:21:35.872 --> 00:21:39.504 - need to debug, especially with entity framework. What's 00:21:39.504 --> 00:21:44.498 - going on? Kind of underneath the covers if you will is 00:21:44.498 --> 00:21:48.130 - whenever your whenever you run these migrations and 00:21:48.130 --> 00:21:51.762 - whenever the database calls are going from entity 00:21:51.762 --> 00:21:53.578 - framework to the database. 00:21:54.720 --> 00:21:58.884 - It's actually taking this code that we write and will look at 00:21:58.884 --> 00:22:02.007 - actual code that's talking to the database here shortly. 00:22:02.800 --> 00:22:07.246 - But it it takes that code that is written and translates it any 00:22:07.246 --> 00:22:08.614 - framework does into SQL. 00:22:09.270 --> 00:22:13.491 - So it's literally making SQL commands from from the 00:22:13.491 --> 00:22:18.650 - C Sharp code that we have, and so you can actually 00:22:18.650 --> 00:22:22.871 - use this SQL profiler to attach to your database. 00:22:26.160 --> 00:22:28.092 - And I, I think this might be 00:22:28.092 --> 00:22:31.848 - pretty interesting, uhm? To go into, I don't know if we have 00:22:31.848 --> 00:22:33.472 - enough time to go into it in 00:22:33.472 --> 00:22:38.184 - detail today, but. Uhm, you can actually a filter on the 00:22:38.184 --> 00:22:39.040 - database name. 00:22:41.070 --> 00:22:44.470 - And then you can watch your database and see what's 00:22:44.470 --> 00:22:48.506 - happening. Um, and I'm trying to remember. 00:22:51.230 --> 00:22:54.948 - If this I I think I might have to add some columns here. 00:22:55.860 --> 00:23:00.858 - Um, and let me know if if one of you guys has done this 00:23:00.858 --> 00:23:04.785 - recently and you remember, um, but you can filter on your 00:23:04.785 --> 00:23:08.355 - database here and then watch everything go across the wire. 00:23:08.355 --> 00:23:12.282 - Uhm yeah, let's see if this template might be better. Has 00:23:12.282 --> 00:23:15.852 - anyone else ever used this before? You guys familiar with 00:23:15.852 --> 00:23:17.637 - this, this SQL Server profiler? 00:23:19.330 --> 00:23:22.940 - It's really helpful for Dean and sharp because you can't 00:23:22.940 --> 00:23:26.189 - necessarily see how it is formatting the strings you're 00:23:26.189 --> 00:23:30.882 - trying to use as parameters, and then you can see how that gets. 00:23:31.470 --> 00:23:35.595 - I called him in SQL Profiler stores to it's really awful. 00:23:36.570 --> 00:23:37.590 - Yeah, exactly. 00:23:39.090 --> 00:23:43.635 - What are you trying to find? I think I got it there, so I was 00:23:43.635 --> 00:23:47.877 - just trying to find the database ID an so we can just call this. 00:23:49.960 --> 00:23:55.840 - Just called the CDI. I'll call it training underscore cities. 00:23:56.480 --> 00:23:59.795 - And we don't have that database yet, so this is the idea I'm 00:23:59.795 --> 00:24:01.325 - going to go for the name. 00:24:02.560 --> 00:24:05.970 - I have a question on the the models whenever would be 00:24:05.970 --> 00:24:08.450 - appropriate to ask that? Yeah go for it. 00:24:09.500 --> 00:24:13.544 - OK cool, so um. Generally like my understanding of C Sharp is 00:24:13.544 --> 00:24:17.588 - like generally you'd only have like a guitar in the Center for 00:24:17.588 --> 00:24:21.632 - a private variable, and then you have like a public variable that 00:24:21.632 --> 00:24:25.676 - you'd put your getter and Setter on till like modify the private 00:24:25.676 --> 00:24:29.720 - variable inside of a class. So inside of the models it looks 00:24:29.720 --> 00:24:34.101 - like for instance if you go to like any of those so their 00:24:34.101 --> 00:24:38.482 - public already and then say like country ID has a guitar in a 00:24:38.482 --> 00:24:39.830 - Setter is there like. 00:24:40.300 --> 00:24:45.292 - A, uh, implicit like private country ID that 00:24:45.292 --> 00:24:46.540 - that's modifying. 00:24:48.380 --> 00:24:52.436 - Yeah, whenever you do it like this, this is a shorthand inside 00:24:52.436 --> 00:24:55.478 - of C Sharp. Whenever you follow a certain pattern. 00:24:57.360 --> 00:25:01.890 - An OK and I would. I would defer to, uh, to, to anyone else who 00:25:01.890 --> 00:25:05.816 - wants to kind of expand on that, but we did syntactic sugar. So 00:25:05.816 --> 00:25:09.138 - in the background, when you actually compile the see it will 00:25:09.138 --> 00:25:12.460 - create a private field that these things will point at but 00:25:12.460 --> 00:25:15.480 - haven't actually physically write all that out over and over 00:25:15.480 --> 00:25:19.708 - again. They just they got rid of that along time ago so you don't 00:25:19.708 --> 00:25:23.634 - need to do it. OK, so it's the same thing, it's just syntactic 00:25:23.634 --> 00:25:26.956 - sugar. OK, cool yeah, good question. And then you can still 00:25:26.956 --> 00:25:29.070 - manually do it, like if you need 00:25:29.070 --> 00:25:32.290 - to. Like further control on what happens on the guitar set 00:25:32.290 --> 00:25:34.864 - assignments, but generally speaking, you just do. That is 00:25:34.864 --> 00:25:36.294 - just a simple get set. 00:25:37.610 --> 00:25:41.250 - OK, so you should be like yeah, I'll go ahead and see me. I'm 00:25:41.250 --> 00:25:45.150 - just going to say so. If you have to do like any kind of like 00:25:45.150 --> 00:25:49.250 - you know. Whatever kind of logic you could, you know not override 00:25:49.250 --> 00:25:52.253 - it, but in the sense like override the setting like do 00:25:52.253 --> 00:25:53.618 - other operations if you needed 00:25:53.618 --> 00:25:59.525 - to. Yeah, you if you're going to do it, you have to do it to both 00:25:59.525 --> 00:26:04.520 - the git and the set. But yeah, so when you look at the code of 00:26:04.520 --> 00:26:08.183 - the it's called property. What it actually is? It's a function, 00:26:08.183 --> 00:26:13.178 - uh, because you can see that it has a body and it's it's got a 00:26:13.178 --> 00:26:16.841 - It's best special function that in in behind it's going to 00:26:16.841 --> 00:26:20.171 - create underscore value. I think private variable which is being 00:26:20.171 --> 00:26:23.834 - said in the center and in together it's getting it so 00:26:23.834 --> 00:26:25.499 - there's some coding behind. Then 00:26:25.499 --> 00:26:29.725 - there's. C sharp was developing over years. They just, uh. 00:26:30.900 --> 00:26:35.879 - As you said Syntax Sugaring, they just uh took out a lot of 00:26:35.879 --> 00:26:38.177 - things, but in reality it's a 00:26:38.177 --> 00:26:40.682 - function. That has variables in 00:26:40.682 --> 00:26:43.904 - the background. Yeah, that definitely makes a lot of sense. 00:26:44.770 --> 00:26:48.686 - And just to put some context around that, for anyone who's 00:26:48.686 --> 00:26:52.246 - kind of wondering about this, that what the what they're 00:26:52.246 --> 00:26:55.806 - talking about here is basically these these properties on the 00:26:55.806 --> 00:27:00.434 - class and one of the reasons that you want to have a private 00:27:00.434 --> 00:27:04.706 - in the public, and these are the private and public are called 00:27:04.706 --> 00:27:08.978 - Access Modifiers. The reason you want to have that is because you 00:27:08.978 --> 00:27:13.250 - may want to make it possible for this particular class to do 00:27:13.250 --> 00:27:14.674 - something to that variable. 00:27:15.600 --> 00:27:21.320 - But not have it be accessible to kind of run that by outside 00:27:21.320 --> 00:27:26.160 - code. So your private my actually make a change to it, 00:27:26.160 --> 00:27:31.440 - whereas the public would just serve up kind of what was there 00:27:31.440 --> 00:27:33.640 - as kind of the output. 00:27:34.300 --> 00:27:39.578 - And so the general idea is that you want to have that private be 00:27:39.578 --> 00:27:43.348 - only available. You know within this class file, essentially an, 00:27:43.348 --> 00:27:47.872 - then the public kind of gives access to the output from that, 00:27:47.872 --> 00:27:52.396 - and So what we're talking about is physically, how is the code 00:27:52.396 --> 00:27:56.543 - doing that? Well at runtime or at compile time, it's actually 00:27:56.543 --> 00:28:01.067 - going to Expound on this and make the private, but since it's 00:28:01.067 --> 00:28:05.214 - just to get set, it knows that it's literally just mechanically 00:28:05.214 --> 00:28:07.476 - filling in the blanks for us. 00:28:07.890 --> 00:28:11.608 - And by only doing the public um properties here, the the 00:28:11.608 --> 00:28:16.002 - compiler knows it's going to go do all the heavy lifting for us, 00:28:16.002 --> 00:28:20.734 - so we don't have to go ride a bunch of stuff redundant Lee, so 00:28:20.734 --> 00:28:24.452 - hopefully that helps explain that a little bit and so I'm 00:28:24.452 --> 00:28:28.846 - going to try to run this and see if you get our database. 00:28:30.360 --> 00:28:31.030 - I think. 00:28:35.300 --> 00:28:38.017 - I don't actually remember if I have to physically make the 00:28:38.017 --> 00:28:39.499 - database or not, or if it. 00:28:40.100 --> 00:28:43.544 - Makes it for us if the user that you're connecting as has 00:28:43.544 --> 00:28:46.701 - permission to create databases that you can create it for you. 00:28:47.420 --> 00:28:50.723 - OK so framework will create the database and the 00:28:50.723 --> 00:28:54.393 - structure. We have that in stuff, but we explicitly tell 00:28:54.393 --> 00:28:56.595 - it not to create the database. 00:28:57.920 --> 00:29:01.407 - Thank you guys. So OK, let's see if I get. 00:29:04.470 --> 00:29:05.758 - That's not our application. 00:29:09.870 --> 00:29:12.286 - Looks like it still is just spinning up. 00:29:35.460 --> 00:29:36.600 - I think that was the problem. 00:29:38.940 --> 00:29:41.560 - And well, that's going. I'm just gonna make sure that 00:29:41.560 --> 00:29:42.084 - it actually. 00:29:43.120 --> 00:29:44.380 - But I named it properly. 00:30:10.170 --> 00:30:12.218 - You guys know me in my break points. 00:30:13.890 --> 00:30:15.416 - Oh yeah, that's how I debug too. 00:30:21.500 --> 00:30:24.880 - Sometimes you accidentally step and you know you stepped into 00:30:24.880 --> 00:30:28.936 - like Oh God. This is like some back end function that goes 00:30:28.936 --> 00:30:29.950 - 80,000 levels deep. 00:30:31.610 --> 00:30:35.246 - You like F11F-11? Oh no exactly yeah. But then you just hit 00:30:35.246 --> 00:30:39.488 - stuff out and then it goes back to where you were. I know James 00:30:39.488 --> 00:30:43.730 - the other day and he showed me that I don't know why I had 00:30:43.730 --> 00:30:47.366 - never even tried but step out he does. It works. It's incredible. 00:30:48.790 --> 00:30:52.599 - I don't know the button for step out and it makes me sad. 00:30:52.599 --> 00:30:56.115 - Mouse over the little one that has the arrow pointing up and 00:30:56.115 --> 00:30:57.580 - see what it says shift. 00:30:59.120 --> 00:31:01.525 - Supposed to run update database 00:31:01.525 --> 00:31:04.780 - in the. In the command line. 00:31:06.040 --> 00:31:09.472 - Yeah, I'm I'm probably missing stuff. I'm just seeing it. It 00:31:09.472 --> 00:31:11.968 - depends. Liking everything. If you have your application 00:31:11.968 --> 00:31:15.400 - startup set to run, the migrator itself in your application, you 00:31:15.400 --> 00:31:19.144 - can do the run. Otherwise you gotta do it through the console 00:31:19.144 --> 00:31:24.136 - in Ceph. The admin API is set up to be able to do that with a 00:31:24.136 --> 00:31:27.256 - storefront is not so that there's not like an accidental 00:31:27.256 --> 00:31:31.312 - like you turn 2 things on and they're both trying to update it 00:31:31.312 --> 00:31:32.560 - at the same time. 00:31:33.200 --> 00:31:34.538 - Um, going on. 00:31:36.110 --> 00:31:39.465 - And I don't know what the differences in core.net core to 00:31:39.465 --> 00:31:43.125 - do that same thing. I'm gonna change this to release and then 00:31:43.125 --> 00:31:44.955 - I'm going to try to just. 00:31:46.400 --> 00:31:48.938 - As far as I think it already has the. 00:31:50.130 --> 00:31:52.450 - As far as getting that database.net core works 00:31:52.450 --> 00:31:53.320 - the same way. 00:31:55.080 --> 00:31:56.436 - Yeah, I think it'll create it 00:31:56.436 --> 00:31:58.189 - for us here. Themaindifferencein.net 00:31:58.189 --> 00:32:02.679 - core is that it doesn't by default pull in all 00:32:02.679 --> 00:32:06.271 - of the related tables where in dot NET 00:32:06.271 --> 00:32:07.618 - Framework it will. 00:32:08.720 --> 00:32:12.380 - So Chris, I would be looking at the start up or something. 00:32:12.380 --> 00:32:15.735 - Or like in the program for something that would tell it 00:32:15.735 --> 00:32:16.955 - to run the migrator. 00:32:41.220 --> 00:32:44.003 - I think that's all of what we've already gone through before. 00:32:45.240 --> 00:32:47.680 - So it's going to be this up here. 00:32:52.810 --> 00:32:58.992 - Yeah, so at the beginning of the configure call in your 00:32:58.992 --> 00:33:00.116 - startup class. 00:33:01.450 --> 00:33:03.950 - You would add a function named update database and then 00:33:03.950 --> 00:33:06.700 - there's a function you can add. I could paste this little 00:33:06.700 --> 00:33:08.200 - article that says what to do. 00:33:11.240 --> 00:33:14.230 - And sorry, I'm not following that. The book here super 00:33:14.230 --> 00:33:17.818 - closely, so that's probably, um, if you're in the book and you 00:33:17.818 --> 00:33:21.705 - wanna tell me the specific step, feel free and I'm kind of going 00:33:21.705 --> 00:33:25.162 - through there now. Uh, I'm not looking at the book, I just 00:33:25.162 --> 00:33:26.470 - found an article that does it. 00:33:27.700 --> 00:33:28.708 - Free of core. 00:33:29.690 --> 00:33:31.500 - Do we wanna try manual? 00:33:33.040 --> 00:33:33.430 - Minutes. 00:33:35.480 --> 00:33:39.440 - And I'm just a going to the page in the book where it kind of 00:33:39.440 --> 00:33:42.608 - talks about that 'cause I'm using the code from the book and 00:33:42.608 --> 00:33:48.019 - I want to. Almost there it looks like it's, uh, we have to put 00:33:48.019 --> 00:33:51.409 - some settings in our app settings. Jason for the default 00:33:51.409 --> 00:33:55.477 - connection and give it our 'cause it's bring it in in the 00:33:55.477 --> 00:33:56.833 - startup CS where it's. 00:33:58.250 --> 00:34:01.858 - On Line 36 and 38, and it's using that default connection 00:34:01.858 --> 00:34:04.810 - string. Did you already set up the app settings? 00:34:06.320 --> 00:34:08.406 - Yeah, I did set that up, um. 00:34:09.720 --> 00:34:10.680 - OK. 00:34:11.700 --> 00:34:14.916 - Well the like as the article I'm looking at says specifically to 00:34:14.916 --> 00:34:15.988 - run a dot migrate. 00:34:16.560 --> 00:34:21.774 - Yeah, an OK. So it it's basically saying Chris what you 00:34:21.774 --> 00:34:27.440 - said? At what those those lines where it says, add application 00:34:27.440 --> 00:34:29.710 - TV context. Um? 00:34:31.700 --> 00:34:34.703 - It's supposed to be doing that, so I'm just trying to read on 00:34:34.703 --> 00:34:36.721 - that really fast. Can you hear 00:34:36.721 --> 00:34:40.906 - me? Yeah, we can hear you. Sorry James. OK I don't know why the 00:34:40.906 --> 00:34:44.434 - article I posted the link that I posted in the chat here has the 00:34:44.434 --> 00:34:47.962 - code that you need. If you just copy and paste it. OK, let's go 00:34:47.962 --> 00:34:50.482 - for it. Yeah, I'm literally almost to the I'm literally 00:34:50.482 --> 00:34:53.758 - going through the pages in the book here. That kind of go over 00:34:53.758 --> 00:34:57.538 - it. And if you for those of you guys that are in the book, feel 00:34:57.538 --> 00:34:58.546 - free to throw out. 00:34:59.730 --> 00:35:03.206 - OK, so so this this update database function is what you 00:35:03.206 --> 00:35:06.998 - would copy in an ad and then just call it from your 00:35:06.998 --> 00:35:09.842 - configure function and then that tells it are actually 00:35:09.842 --> 00:35:12.686 - tells the context that database two do that migrate. 00:35:13.930 --> 00:35:17.550 - I think it's in the configure, not the configure services. 00:35:17.550 --> 00:35:18.636 - Sorry, thank you. 00:35:22.500 --> 00:35:23.540 - So we'll need to. 00:35:24.410 --> 00:35:29.630 - OK, did you already update your application? DB context, yes. 00:35:34.450 --> 00:35:36.448 - I did not I don't think. 00:35:39.960 --> 00:35:44.160 - Yeah, I kind of want to go with but OK, so let's just put this 00:35:44.160 --> 00:35:47.800 - here for a moment. Um, 'cause it literally goes over this in this 00:35:47.800 --> 00:35:51.720 - book and I love to just stick with that if it and it should 00:35:51.720 --> 00:35:53.680 - work for us. I just need to. 00:35:57.830 --> 00:36:00.716 - OK, so let me let me show you what I'm looking at on 00:36:00.716 --> 00:36:02.714 - the book, 'cause I think that'll help you guys. 00:36:03.810 --> 00:36:08.514 - I feel more more patient here as I go through it, OK? 00:36:35.850 --> 00:36:37.218 - And I think I'm. 00:36:37.840 --> 00:36:41.890 - I'm beyond what was needed to create it, uhm? 00:36:47.030 --> 00:36:48.955 - Can you search for database dot migrate? 00:36:51.230 --> 00:36:53.046 - Yeah, I'm gonna go back to here and. 00:37:05.490 --> 00:37:10.033 - Yeah, let's just go ahead and just do it through the. 00:37:10.760 --> 00:37:11.730 - Package manager. 00:37:16.040 --> 00:37:18.960 - And actually, I think that in the book it's talking 00:37:18.960 --> 00:37:21.588 - about doing it through the command line, so, um. 00:37:23.120 --> 00:37:26.816 - I'm gonna see if I can get to that section and do it that 00:37:26.816 --> 00:37:29.984 - way. If the book is doing it through the command line then 00:37:29.984 --> 00:37:32.624 - they might not have the migrate in the configure with. 00:37:33.990 --> 00:37:39.934 - Yeah. So you wanna go up to the tools to find the nougat 00:37:39.934 --> 00:37:41.170 - manage package console? 00:37:42.430 --> 00:37:43.920 - Yeah, I'm actually there right 00:37:43.920 --> 00:37:47.798 - now. Um? So I, uh. 00:37:49.680 --> 00:37:51.700 - What is it? Update database? 00:37:53.220 --> 00:37:56.148 - Oh no, I'm sorry, I know. 00:37:57.750 --> 00:38:02.535 - OK, just be careful which project you have said his dad 00:38:02.535 --> 00:38:08.190 - that so I'm not sure should it be.net or is it just update 00:38:08.190 --> 00:38:12.540 - database? I'm not sure how it works in the course. 00:38:13.730 --> 00:38:15.520 - Is it different in corporate? 00:38:17.150 --> 00:38:23.750 - Same in both. It's always a verb dash now. So update dash 00:38:23.750 --> 00:38:29.250 - database interesting. If you look at the book it's talking 00:38:29.250 --> 00:38:32.550 - about running the command net F 00:38:32.550 --> 00:38:36.948 - database update. Um, which is kind of interesting. 00:38:38.670 --> 00:38:41.630 - So I think if we wanted to can try that. 00:38:42.960 --> 00:38:45.860 - It was originally just database update and then Andy Framework 00:38:45.860 --> 00:38:49.340 - Core came out which does it a little differently, which is why 00:38:49.340 --> 00:38:51.499 - there's. Different commands now. 00:38:53.400 --> 00:38:55.983 - Do we have to add the initial migration first? 00:38:57.210 --> 00:39:00.360 - It's already there. It looks like OK, just yeah. 00:39:02.180 --> 00:39:05.108 - Don't mind me guys, I'm I'm sorry that I'm kind of all 00:39:05.108 --> 00:39:06.328 - over the place with this. 00:39:07.820 --> 00:39:08.210 - Hum. 00:39:09.750 --> 00:39:10.700 - Is like. 00:39:12.240 --> 00:39:15.219 - Today's update well, yeah, I definitely. I definitely could. 00:39:15.219 --> 00:39:18.529 - I could have prepared better, but uhm, hopefully you're kind 00:39:18.529 --> 00:39:20.515 - of getting to think through it 00:39:20.515 --> 00:39:22.850 - here some too. OK. 00:39:23.510 --> 00:39:25.798 - And may need to run it in a different directory here. 00:39:28.220 --> 00:39:29.138 - Just one 2nd. 00:39:31.250 --> 00:39:36.128 - Well, isn't PowerShell based on verb dash now like? 00:39:36.680 --> 00:39:38.720 - Update this database. 00:39:41.960 --> 00:39:43.290 - He then. 00:39:45.680 --> 00:39:49.957 - The documentation says just to run it as he did, so I don't 00:39:49.957 --> 00:39:52.918 - know if it's a different committed in PowerShell than 00:39:52.918 --> 00:39:58.860 - the. Yeah, try opening up. Um, yeah, I'll try opening up. 00:40:00.630 --> 00:40:06.015 - Yeah, I can do it from here to I don't know that it's going to. 00:40:13.130 --> 00:40:14.999 - Yeah, I think I think that it's 00:40:14.999 --> 00:40:19.647 - using command line. And I'm I'm trying to remember what do you 00:40:19.647 --> 00:40:24.729 - hit here to jump to come in. Seems like type in the CMD and 00:40:24.729 --> 00:40:26.181 - press enter. Thank you. 00:40:33.700 --> 00:40:36.659 - And I'm just wondering if maybe that's just the wrong folder. 00:40:47.430 --> 00:40:52.617 - OK, and I'm I'm kind of poking through to see in this book. 00:40:55.360 --> 00:40:58.418 - Me asking why do we use visual studio's package manager console 00:40:58.418 --> 00:41:00.920 - to execute these commands? The reason is simple. Unfortunately 00:41:00.920 --> 00:41:03.978 - doing this won't work because the commands need to be executed 00:41:03.978 --> 00:41:05.368 - within the project root folder. 00:41:06.030 --> 00:41:09.050 - Which is not where the package manager console commands are 00:41:09.050 --> 00:41:12.118 - executed. It is unknown whether that behavior would change in 00:41:12.118 --> 00:41:15.004 - the near future. Until it does, we have to use the command line. 00:41:15.004 --> 00:41:18.326 - OK, there you go. Transfer update dash database in the 00:41:18.326 --> 00:41:21.747 - package manager. Yeah, like that command won't work unless you do 00:41:21.747 --> 00:41:25.479 - it from the command line, but the other ones like the older 00:41:25.479 --> 00:41:28.589 - style of update database should work from inside the package 00:41:28.589 --> 00:41:29.833 - manager console in Visual 00:41:29.833 --> 00:41:33.324 - Studio. And they're both designed whether you're working 00:41:33.324 --> 00:41:37.380 - or or dot NET Framework, we will do that. This doesn't work, but 00:41:37.380 --> 00:41:41.124 - check this out. This is exactly what we were seeing is our 00:41:41.124 --> 00:41:43.740 - error. And if I'm not mistaken. 00:41:45.230 --> 00:41:45.820 - Um? 00:41:49.360 --> 00:41:54.582 - So yeah, it looks like basically there can be a new get, um, new, 00:41:54.582 --> 00:41:58.684 - get package. Conflict that causes it to not work, but 00:41:58.684 --> 00:42:01.428 - they are recommending that we do it from. 00:42:04.530 --> 00:42:08.690 - From the root and then run that command and it seems like we're 00:42:08.690 --> 00:42:12.764 - just missing. Uh, maybe missing or you get packages, I'm not 00:42:12.764 --> 00:42:14.696 - sure, so I'm just trying to read 00:42:14.696 --> 00:42:17.000 - through this and. Um? 00:42:18.020 --> 00:42:21.048 - Resolve it. And let me switch back to my. 00:42:23.360 --> 00:42:24.400 - Element box. 00:42:25.590 --> 00:42:26.170 - Yeah. 00:42:27.560 --> 00:42:30.164 - And so you you guys are thinking, just go ahead and do 00:42:30.164 --> 00:42:34.070 - this for. Simplicity right update dash database. 00:42:34.770 --> 00:42:35.320 - Thanks. 00:42:42.310 --> 00:42:43.258 - Seems to be working. 00:42:49.660 --> 00:42:50.179 - There we go. 00:42:54.330 --> 00:42:58.698 - OK, awesome, um yeah, uh, so that should work in according to 00:42:58.698 --> 00:43:03.430 - the book, um, we just need to workout a issue with the package 00:43:03.430 --> 00:43:08.890 - is that it has to use to to do that. It's not finding them. So 00:43:08.890 --> 00:43:10.710 - that's what the issue is. 00:43:13.420 --> 00:43:16.108 - But the interesting thing about this, so we 00:43:16.108 --> 00:43:17.788 - have our tables an uhm. 00:43:19.320 --> 00:43:23.004 - I mean they they literally are going to match what's in our 00:43:23.004 --> 00:43:26.995 - code that we were looking at earlier so you can see we've got 00:43:26.995 --> 00:43:30.679 - her ID for both tables and then we have our foreign key 00:43:30.679 --> 00:43:32.214 - relationship from the cities to 00:43:32.214 --> 00:43:37.762 - the country. Uhm, but this is really interesting. Uhm, the 00:43:37.762 --> 00:43:42.523 - migration history table and this is basically what's physically 00:43:42.523 --> 00:43:44.110 - going to enable. 00:43:44.870 --> 00:43:50.074 - That kind of. Just enforcement if you will, of the the code 00:43:50.074 --> 00:43:54.320 - first and making sure that it's using those migrations and this 00:43:54.320 --> 00:43:58.952 - kind of goes right into what James is going to be talking 00:43:58.952 --> 00:44:03.198 - about later, which is just kind of dealing with migration issues 00:44:03.198 --> 00:44:07.444 - with entity framework. An just kind of before we get into. 00:44:09.790 --> 00:44:13.720 - Yeah, I almost think it might be best for us to go James 1st and 00:44:13.720 --> 00:44:16.602 - then Jesse just because this will all kind of tie together 00:44:16.602 --> 00:44:19.746 - even more will jump out of the moment if we with me. 00:44:20.680 --> 00:44:24.992 - Yeah, um, but I'd love for you guys to just kind of point out 00:44:24.992 --> 00:44:28.996 - if you have any questions on this uhm or any kind of topics 00:44:28.996 --> 00:44:33.000 - that you would like to go into here before we shift over to 00:44:33.000 --> 00:44:36.388 - James. And this is kind of interesting. Well I'm kind of 00:44:36.388 --> 00:44:40.392 - standing by if you guys, do you have any questions so you can 00:44:40.392 --> 00:44:41.932 - actually see the SQL commands 00:44:41.932 --> 00:44:47.040 - that it created? And just kind of To to play around with it. 00:44:47.040 --> 00:44:50.988 - Some, uhm, I'd love to see if we can turn this on. 00:44:52.000 --> 00:44:55.576 - And then I'm just gonna do. 00:44:56.360 --> 00:44:58.404 - This command and see if it's actually. 00:44:59.460 --> 00:45:00.820 - The profiler is running. 00:45:02.940 --> 00:45:06.780 - OK, so you can see that if I run a command, well 00:45:06.780 --> 00:45:08.380 - I have this profiler on. 00:45:09.580 --> 00:45:12.990 - Um, the profiler is actually seeing that command that I just 00:45:12.990 --> 00:45:17.331 - ran. So it's watching the commands and just as a 00:45:17.331 --> 00:45:21.500 - reminder, you can get to the profiler by going to SQL 00:45:21.500 --> 00:45:24.532 - Server Management studio, going to tools and SQL 00:45:24.532 --> 00:45:27.943 - Server Profiler, and then when you're in the profiler 00:45:27.943 --> 00:45:29.080 - you can specify. 00:45:32.880 --> 00:45:37.170 - You can specify a database and there are different options that 00:45:37.170 --> 00:45:41.850 - you can choose, like tuning is a good option to choose typically, 00:45:41.850 --> 00:45:44.190 - and then you can select the 00:45:44.190 --> 00:45:46.806 - database name. By specifying a 00:45:46.806 --> 00:45:50.420 - column filter. And then putting your database name in there. 00:45:52.620 --> 00:45:55.513 - And you don't have to do that, but you know you 00:45:55.513 --> 00:45:58.143 - probably don't want to sit there and watch all the 00:45:58.143 --> 00:46:00.510 - commands, especially like for clarity you don't watch all 00:46:00.510 --> 00:46:03.140 - the commands on all the databases that would blow up 00:46:03.140 --> 00:46:03.403 - your. 00:46:05.100 --> 00:46:08.520 - Results here, but you can actually see whenever this 00:46:08.520 --> 00:46:11.940 - application is running an whatever it runs its migrations. 00:46:11.940 --> 00:46:16.120 - You can actually see the data that's getting sent by entity 00:46:16.120 --> 00:46:20.680 - framework to create the tables or modify them, and then also to 00:46:20.680 --> 00:46:25.240 - run the commands and. This is a really, really helpful tool if 00:46:25.240 --> 00:46:27.900 - you're dealing with entity framework for performance 00:46:27.900 --> 00:46:32.260 - tuning. Because what entity framework is doing is it's 00:46:32.260 --> 00:46:36.460 - literally going in and building SQL commands from C code. 00:46:37.310 --> 00:46:42.040 - Um and that can be problematic if it's not done efficiently. 00:46:42.650 --> 00:46:45.098 - Because technically the you know the way that it's 00:46:45.098 --> 00:46:48.362 - building. It may not be optimal, and I know a lot of 00:46:48.362 --> 00:46:51.626 - the back end team members have seen this where you know if 00:46:51.626 --> 00:46:55.434 - you if you put A to list in the wrong place and that's the 00:46:55.434 --> 00:46:58.154 - most probably one of the most egregious things that we 00:46:58.154 --> 00:46:59.786 - probably almost never do that, but. 00:47:01.350 --> 00:47:05.640 - Any kind of issue with building out the the link up? 00:47:06.570 --> 00:47:12.688 - It really can cause a problem an and so you can analyze what it's 00:47:12.688 --> 00:47:17.058 - physically doing by looking at this profiler and seeing what's 00:47:17.058 --> 00:47:20.956 - physically running. Against the database up with entity 00:47:20.956 --> 00:47:24.610 - framework. So entity framework has some major advantages in 00:47:24.610 --> 00:47:28.264 - that whenever you're writing your code and you're building 00:47:28.264 --> 00:47:29.888 - out your actual application. 00:47:30.670 --> 00:47:35.636 - Um, your you know your code to get data from the database, so 00:47:35.636 --> 00:47:39.456 - this is really kind of the culmination of this entity