How to use SQLite and Entity Framework Core in Blazor

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
just to make sure that we are up and live everywhere I am supposed to be up and live looks like we are on YouTube and I'm looking here and we're live on Twitch which is great so if you have any questions about this or comments or anything else feel free to jump into the chat our chat is always uh pretty fired up and pretty fun so yeah without any further Ado let's just jump right into it so I'm going to create a new application now this here is going to be what we're going to do is create another Blazer server application like we did before that manages employees so we're going to be able to take a list of employees show them edit them delete them create new ones all that kind of stuff and we're going to do it all with a Blazer server application and we're going to use sqlite so if you don't know what sqlite is Google it it's a very awesome small file based database system so we can take this and publish it off to like Azure websites or something like that and we don't have to have any other database system connected we don't need Azure SQL we don't need a SQL Server we don't need any external database services that will all be located on a file on this sqlite file database so it's it's awesome and we're going to do it today so I'm going to call this employees I believe is what we uh called it before but we're going to call this employees we're going to set this location and this is going to be dot net 7. we're not going to use any authentication with this we're not going to use Docker or anything like that so this is going to be a basic simple Blazer application that you can create uh right alongside me if you want like if you're watching this uh in the past you could just pause it because we uh stream off to twitch but we also record it on YouTube so this will be great and uh one last tech check that I got to do here yep okay perfect so we are ready to go with a brand new blazer application you've seen this a million times let's press play let's see what it shows uh make sure Bones on silent and this first time it loads up it takes a little while but here it is Hello World how's Blazer working for you blah blah blah we don't really care too much about most of the functionality in this application as it's scaffolded out so we can take out things like fetch data Razer we can take out counter razor we don't need that and we will go in here to our shared layout our nav menu just to make things simple we'll take out the counter and the fetch data there and then I believe we have a service that loads up here yep weather forecast service pull that out now let's see what we have there we go so now we just have a basic hello world employees Etc just a plain old web page here this webpage is going to be our employees database manager so now we've got all this stuff in here we need to add in so we're going to use Entity framework core now the reason I'm doing all of this is to basically show how you can have there there's a few reasons to do this one reason is the sqlite like I said doesn't require any database connection none at all it's just a file that's going to sit on here that's going to be published with the website another reason we're going to do it we're going to use Entity framework core because there isn't a ton of code involved it scaffolds things out it does all the SQL it generates SQL for you all of this stuff and it's supported so Entity framework core supports SQL Lite and I will show you as we put this in here totally supports it so you don't have to write any of the SQL stuff transaction map none of that stuff it's all done for you so what this is is just basically a if you have a small data set and I say small like gigs instead of terabytes right you you can use this and it's kind of a self-contained system and it's very fast I mean it's lightning fast as you'll see which is very cool so jump on here really quick oh yeah I forgot to make a a little change here there we go all right and hello everybody from twitch and YouTube I see a ton of viewers today which is awesome so I have here I have this article so I wrote an article based on this and I did all the create read update delete stuff all of it and I put it in a list so I'm going to follow that article to make this faster so there's not going to be as much hand typing and code and trying things uh there's going to be a lot of we're just going to kind of rip through it so we can see the basics of how it's done and as always my uh email is always open Jeremy Dash Morgan at pluralsight.com if you have questions about what we're doing or why we're doing it so we'll go through here and the first thing we want to do is open up our package manager console and we're going to install some of the Entity framework core stuff so I'm just going to paste this in here I'm typing in net add package Microsoft dot entity framework.core.sqlite see that's the the important extension there is the SQL light because most of the time folks are using like SQL server or something like that and let's see it says uh could not find any project in employees I forgot I need to actually go into the project and then so you type in CD employees go into your project and there we go pull that in then we're going to drop in Entity framework core tools this one is not specific to sqlite this is just The Entity framework core tools that you use anywhere else same with the design we're going to add in design because what we're going to do is do the code first Entity Framework so those of you familiar with that you build classes plain old class objects and generate your database from that it's very cool it's uh super easy to modify like when it comes to migrations is when it really comes in handy because you'll make changes to your objects or your classes I should say that changes your objects and then you can add those into a migration changes your whole database for you it's pretty cool we're going to update.net Entity framework even though I've already updated it um it's in the article so we're going to do.net Tool update.g.net EF so now we're running the latest stable version which is 7.02 I'm running the latest version of microsoft.net I'm running the latest version of Visual Studio this is not a beta version just the latest updated version and then we're we're just updating everything so that everything's on.net 7 and we're ready to go now we need to create our actual sqlite database and this will be fun because it is super super easy we say new database then we have to choose where it's going to go all right so go in here and I know that I'm in repos which is a huge huge thing for me there we go employees you can see last week's is in there we're going to select employees and data and this is where we're going to store it we're going to call this uh employees.db or sqlite database and then save now here it it comes up with a as soon as you create a sqlite database it then does this table definition so that you can build tables and things like that we're not going to do that we're going to let any framework build tables for us so this is really all all you need to do you can do this and then uh close database now when I go into my data folder ta-da there's employees.db right now it's super tiny does nothing um and we will want it to set to copy if newer here but that's really kind of a more of a deployment thing you'll actually want to only copy it once basically if you're going to do this in a production application so now we've got our our employee database it's saved we don't need to um do anything with the table definition or anything like that just close the database and now we want to create the database model now if you watched our previous streams we're going to use the exact same data structure as the previous streams and with those what we did is we had a first name last name email address their department and a picture now where I get this from is from makuru.com let me bring that up really quick for those of you who have never used it it is pretty awesome so I went to mockeroo.com and just generated some fake data so all this data here is not production data it's not anyone's real name or address we went through and selected first name last name email address department and Avatar and Avatar is generated by the service which we'll see here in a little bit so that's pretty cool I'm actually going to put that mock data into let me find it here mock data CSV I'm going to take that and put it right into my data folder let's just open it up really quick and you can see we have an ID first name last name email department and Avatar the Avatar is actually this robahash.org type thing and it just calls a bunch of different images so the images are actually hosted elsewhere they're not hosted in database or hosting a reference and we will address that soon how that works and everything so what we need to do is create an employee class I'm going to create that in data also because I'm going to try to keep try to keep everything kind of in in data as much as I can right kind of the best best way to approach that so we'll go in here to data we're just going to create a plain old class object so new item class this class is going to be named employee employee add in this class I can just copy and paste I'm going to have this we'll make this a little bit bigger so you can see it we have our ID it's an integer it's already generated in our fake data so we don't have that auto update type thing going it's just a list of one through 100 or whatever we have our first name last name email department navatar so this object when we create objects from this we're going to pass them all over the place we're going to pass them back and forth through the form we're going to drop them into the database everything in this employees table will come from this schema right here and that's what the code first and the framework is all about we're going to tell Entity framework this is a table this is a collection of data we want you to store it and do the all the creating and reading and updating and etc for it so that'll be cool and like I said this is just a class plain old class object or Poco as we call them and next we need to create a context now the context is something that we're going to use quite a bit also and we're going to use the Entity framework core context so we're going to go add here here I'm also going to do just a plain class object however we're going to we're going to make some changes to it I'm going to call this employee data context cool so now we have a public class employee data context but we want it to extend DB context in order to do that we're going to have to add a Entity framework core as you can see we have it here perfect so now we're using Entity framework core this is a DB context EF core knows exactly what this is supposed to be so they know that uh you know this is supposed to be a database context and we're going to do things with it makes it pretty expected so we're going to create a connection string and it's the most simple connection string you've ever seen in your life however we're going to connect we're going to create that and then we're going to read that connection string in this class but it doesn't exist for right now however we're going to copy all of this stuff in and see protected read only eye configuration configuration and then we're going to create a Constructor that passes that in say just like this and then we're going to say configuration is configuration actually this should be lowercase a little less confusing so we're passing in and we're just passing in this configuration into this employee data context class so that we can use that configuration to read our connection stream if that makes sense and I am going to do a quick screenshot of something really quick here okay perfect and this is part of the tech check where I'm just making sure everything is great here I don't see a lot of stuff in the chat so that's why I'm I'm checking this just to kind of make sure that we are actually up and live and ready to go so we're taking this configuration string we're going to create that in a few minutes next we need to create an unconfiguring method so what this does is it's called when the context is created and once again I'm going to copy this in so we don't see a bunch of slow typing we don't want this to be an eight hour stream so copy this in and explain it in here on configuring we pass in the DBI context options Builder which we're going to build that and we're going to start that in our program.cs but we pass this into on configuring and then for options Builder we're just going to tell it use sqlite which again this is probably different from what you've seen in other parts of Entity framework core where you've used SQL Server it's usually use SQL server or something like that this one's use sqlite and then we're just going to get the connection string for employee.db that will connect us to sqlite and then we need a DB set if you've built these contacts before then you know the DB set is essentially the table essentially everything in the table our employees table or our employee table everything in it will be employees right here and so we can pass that database or that DB set and we could do things like updates and creates and all that stuff so here's our final class well it's not final quite yet but this is our class we're going to add some stuff to it here in a little bit but now we need to create that connection string we do that in app settings.json as you can see we have a some logging in here right here we're just going to put in once again copying and pasting action strings our employee DB connection string that we're looking for is going to be data source equals data employees.db the reason we have two slashes in there is because a slash indicates an escape sequence and so if we put slash something looks for an escape sequence if we put two slashes in a row then we know that it's not an escape sequence it is actually a backslash and that's what we need to go to data employees.db and remember when I said this is going to be the simplest connection string ever um that's it it's employee DB is employees.db one of the things you might notice there's no authentication information there's no anything so anybody that has access to your employees DB I think I said this in the last stream too anyone that has physical access to that database has access to all of the data there are ways around that but we're not going to focus on those today because we're just going to do some really quick like create read update and delete stuff I just noticed our weather forecast is in here gonna get rid of that we don't need that let's see if we can build this let's see if I've forgotten something nope okay cool so it builds so now we have that the uh we have the connection string we have the context next we need to add our services so we're going to go in here to program.cs and we're already using employees data here that's good but we need to add Entity framework core and configuration which I'll copy and paste those now we have Entity framework core and configuration in because we're going to once again create that configuration that we can pass into the context context is going to read that configuration read our database connection string and connect to the database all of that good stuff the first thing we need to do is pull in that connection string so we can do that pretty much anywhere we could do it right here we have to do it that's true we have to do it after Builder so I shouldn't say we can do it pretty much anywhere we have to do it after the Builder is instantiated right here then we're going to say connection string get the Builder configuration get connection string of employee.db then down here you see where it says add services to The Container we're adding razor pages and server side Blazer those are put in automatically for us so that we can create our application we need to just add another one here and uh once again I'm copying and pasting boom this one's a long one so what we're doing here is we're adding a service to The Container we're adding a DB context Factory so that's something that's just gonna it's a factory you know it it's going to create our employee data context Singletons here and then for options we're just passing in this option here to use sqlite SQL connection string so we're doing that twice we do it in the context and we do it here just to make sure that we're always using that sqlite connection string every time we we create this every time the the context is spun up it's going to use that configuration which is great so then it goes to Builder brought build builds the thing so now we're actually ready to create our initial migration now one thing I can do here just to make sure that everything was done right is a new build build we can run it this just makes sure that everything I put in there is is good you know it's it's kosher I didn't forget anything that I know of so now we can actually create that first migration so you've probably done this before this is going to be exactly like uh creating any other Entity framework core migration.net EF migrations add we're going to call this initial create fingers crossed it will work gotta find that context it'll find that employee class yep and we're good so then we just dot net EF update now at this point theoretically Entity framework has opened up that sqlite database and create a table let's check it you know it's a whole prove it thing that the QA folks always say they always say prove it well let's prove it because so far let's see open I don't see it here browse data tables looks like we still have zero tables close open ah see I could not prove it so.net EF update now this should work let me make sure I'm opening the correct database and I might just have to close this open database we're going to go in here to repos or repos we're going to go to employees employees data employees DB and I still don't see any tables here so it might have been because I had that table or I had that database open but usually it will fire back some kind of error it's equal light that's right you can't open this I can open with sqlite Explorer so let's do that really quick DB browser for sqlite browser for sqlite okay and we still don't have the tables that's interesting so maybe we need to insert the data into it to make it do that migration I'm going to do a a second migration just for the heck of it create two and it's fine update okay we browser for sqlite open the database it's still 8kb so I don't think it's got any tables in it so let's see here look through my notes make sure since connection string I mean it looks like everything is B however I think I need to put in some create stuff which is fine we will we'll move to that um in this next part because what we're going to do is um oh that's right yeah I I'm doing on model creating next and on model creating is what will actually create that model for us so once again I'm going to go and copy in paste here we're going to go into our employee database or employee DB context and add a new method this is our oncreate model creating so this is when the model is uh being created so it's going to create that initial table structure Etc we can add in right here I've got some fake data and this comes from our mock data CSV that we have here and I just put in that number one here as a record to insert but instead of doing that I think we're going to load up Nimble text in the CSV data and we're going to just create all of these things at once we're going to create 100 records this right here will actually create our SQL database so initial create we're going to say create employee table is what we'll name this add build starts dot net EF update this should actually build that table for us that we're looking for even though I just noticed I have it open again so probably not close it we're going to do a rebuild and then we're going to create that table create employee table two net EF update build started and it's still not creating so we're going to see if it creates it once we seed the data in if not we will certainly get a huge error message so in here I have some of the CSV data from before but we're going to take our newest CSV data we're going to take that from this mock data CSV copy all of it now in previous streams we took the CSV and actually imported it into that sqlite database so that the uh so that the data was in the database kind of natively what we're doing here is we're seeding it so every time somebody creates a new instance of this application they're going to get this big pile of new employees in here so now what this does is see if I can make this a little bit bigger so you can see here what we're doing is we have CSV data it's all separated by commas we've got one two three all the way down to 100 and what we're doing and I should have started that at zero but that's fine what we're doing here is we're saying new employee ID equals zero which is going to be this first field first name dollar sign one is going to be this one last name and so forth and this Nimble text program that's another thing to Google if you've never used it Nimble text Will convert the CSV it'll use this pattern and convert it into c-sharp code you see that isn't that beautiful it's amazing you just have to remove the last comma but other than that this is valid c-sharp code where it's going to create a new employee for us for our uh seating so let's go in here boom look at that and like I said we got to remove that last one actually we're going to go all the way back here before we had a model entity employee here and then this is where we're going to type in all that CSV data we're going to make this thing create 100 new employees whenever this is a brand new database seems wild right and then the last one we close it zoom out a little bit check that out a whole bunch of c-sharp code oh control looks like a for some reason it's not formatting it but that's okay we can take all of these and just tab them forward a little bit so it looks a little nicer but these will all be created for us tab tab tab tab undo that last tab there we go now when we run this migration this should insert all of these records for us which is pretty awesome right so we've got it dropped into the code now we're going to do another.net uh migration here zoom in make this bigger so you can see what I'm typing and we're going to say.net EF migrations add seed data and you can see this one takes a little bit longer right and then.net EF database update we're updating we're building up now it's applied all those migrations so these were the uh basically it was waiting for that seed data to go in to apply all the migration so now we'll be able to see all of that SQL that we're the the tables and stuff that we were worried about let's open that up now it's 36 KB you can see and now we can see all of our employee data here and we just do a quick spot check to make sure ID that's an integer Avatar that's a URL that's what we expect Department is what we expect now we would if we wanted to normalize this a little bit we would definitely put these into their own table but for right now it's freeform text just to goof around email looks like an email address first name looks like the first name last name looks like the last name so now we have a hundred we'll close that database now we have a hundred records in our database ready to go so what do we do now well now we need to do the actual crud operations which is the title of the stream right crud so what is crud crud is create read update delete um and it's pretty self-explanatory right we want to be able to create records we want to read records update them and delete them so we're going to do all that the Razer component with one razor component we're going to do all of that so it's going to be a little bit different from what you see now there's a lot of tutorials out there on doing this similar kind of stuff like crud operations with blazer there's a lot of them they tell you to build individual Pages for each one of them we're not going to do that um and we're going to do this with sqlite so basically this is kind of our own unique little take on the usual Blazer uh tutorials which a lot of them are great if you want to use uh one of the reasons I wrote this article is if you want to use sqlite with Blazer and Blazer server um you have to piece together several different tutorials which is why I decided to write this article that just does one oh hello Surly Dev thank you for coming into chat and Surly Dev says if you're not on Twitch which you should be because that's where things are cool says I've been playing with makuru since I saw you talk about it a few weeks ago makuru is so awesome I actually did the paid version of it so I think it's like 50 a year so that you could generate a hundred thousand records or whatever and yeah a load of crud with Jeremy Morgan would have been a good name for the stream uh I could probably change it I think you could change that in real time uh I think because that's such a good title uh I think I'm gonna change it uh the title I have for the article is blazing fast crud so a load of crud with Jerry Morgan I'm changing it and yes that's a good reminder to post my little ad you're not following us on Twitch you should be if you're following us on LinkedIn or YouTube or Twitter or anywhere else and you're watching this you should watch us on Twitch this is where we're going to do the most shows we have actually a really cool uh event coming up in April where we're getting people together and we're going to get them on the live stream we're going to get them in front of this camera and uh it's going to be down in New Orleans we're going to get them together interview them we're going to have all kinds of cool stuff and we're gonna have a lot of fun and we're going to do that on Twitch so if you're not following us on Twitch you should be following us on Twitch we're always always always on Twitch that's as surely Dev says it's where the cool kids hanging out okay so now we've got our data so and I said I'm going to do this a little bit different so if you've taken Blazer tutorials in the past you're going to notice that I'm doing it different and that's fine it's not that those tutorials are wrong it's just kind of a preference thing for me a first thing I'm going to do is wipe this out so our index will be just blank let's make sure everything builds I forgot I hadn't done that so there we go home this builds everything's cool and then so I got rid of that survey prompt so we can delete survey prompt now we don't need that and what I'm going to do is create a code behind file if you watched my streams in the past or read my tutorials or blah blah blah you know I love the code behind even though for some reason I'm just momentarily forgot how to create one so I'm going to create a class this is going to be another plain old class object I feel like in Visual Studio we have all of these different like really cool things and I feel like I'm always just creating classes and interfaces right here and razor components I guess I do create razor components so these top three right here are really the only ones that I ever use on here but I use class probably the most so I'm going to name this index dot razor .cs by naming it index.razer.cs it knows that it's the code behind for the index.raiser all we have to do is put in partial class and then it will add into the regular index class cool right awesome so for a page title actually I'm going to close these and I'm going to pin these because we're going to be using these a lot now for my title I'm going to put our employees which is cool works these are our employees and so we've got our code behind here we've got a partial class and the first thing we're going to do is this is where we start to stray from the tutorials I'm going to put in a flag called show create if show create is true it shows a creation form in Razer that you can create a new employee with if shofcreate is false it's hidden that's the only thing this thing does so what we do is put in a property it's going to be a Bool we're going to call it show create and that's it now one of the things that we have that's sort of a Constructor and I'm going to copy and paste this also this is sort of a Constructor for a Blazer component on initialized async is called whenever this is called basically or whenever this component is called so as it loads up this is the first thing it's called we're going to put a bunch of stuff in here one of the things we're going to do is we're going to put in show create is false because we want it to be hidden like as soon as it's and this is showing me an error because it's supposed to be a task it's fine we'll we'll Rectify it you know as we go on and we need to pull in here um so we're going to have a create screen we also need to pull in our employee data context we're making it nullable in case we have some kind of problem where it doesn't load then it just ends up being null and then we'll do null checks down the line so this is this is a very rudimentary kind of crud operation it's very uh simple I guess you could say but we are going to real quick okay sorry I just had to check something but we are going to do a little bit of checking just saying if it's null that means something's probably wrong we'll move on if you're going to build a production application you'll want to put in a lot more checking than that you'll want to find out why it's null why it doesn't connect Etc log it all that but we're not going to do that today because this would end up being an all-day stream now one thing that we want to do we're going to create a form right that creates a new employee so we need to create an employee object in there we're going to make this one public Public Employee new employee and what this will do is uh this just basically has an employee object that we can create with the Blazer form we're going to bind it directly to this object when we create it we want to bind it to the form and uh let's see where are we going to put that I'm getting a little ahead of myself but we're going to bind the form to this new employee then we'll be able to save it and we'll just insert a new employee and it's good this might seem like a lot of code if you're watching this and you haven't done a ton of uh Blazer development or c-sharp development you might think this is a lot of code but at the end of it it's actually a lot less code than it used to be when it came comes to working with databases so here we're going to create a new function method whatever you want to call it we're going to say public void which means it returns nothing and we're going to call this show create form also create form does is turns show create to true and you'll find out when we hit the display section why that matters we're gonna show crate 2 so it shows that create form but we're also going to create a new employee object so we're going to say new employee which is our friend up there equals a new employee so when we do that create form we know that that the whole intention of showing that create form is to create a new object to create a new record to create Etc so this is where we're going to do it we'll create the new record here that record will be bound to the form Fields so that any changes in those form Fields will automatically be changes here in this employee object and then that's the employee object that we pass to Entity framework core that's going to update our database so pretty awesome you know um see what we need oh now we need to do the actual creation part of it so this these two things will show the form then you type the stuff into the form what do we do now we want to hit save that's where this comes in this is going to be the save we're going to call this create and once again we're going to do some copying and pasting async task create new employee this is going to be in a synchronous operation and I'm going to copy in our context we need the context here so ah as you can see I did not inject this into the form yet whoops so our code has no idea what I'm talking about when I when I do this and I think it's something like DB context I will worry about that in a minute I don't remember what the exact one is but we need to inject it for it to be used in here and we'll do that and then we're going to say again I'm copying pasting this is actually for database code this is actually super abstracted and I love it so we're going to say if new employee is not null which new employee is this one that we created up here it's going to be bound to those form items if it's not null then we're going to go to the context in employees we're just going to add that new employee then we'll save changes async and it's pretty much that simple but one thing that we need to do is we need to set show create to false again because otherwise that create screen will remain open after we create a new record so yeah I think that's good um actually I have my inject string so let's go back this is this part is all we need for the code behind for the back end of this believe it or not all of this will add a new employee on the back end which is awesome and I'm going to take a very quick break here for a second and I'll be back in just a couple of minutes at the most and now I'm trying to find where that uh there it is all right now I'm going to be there it is all right oops there we go all right I'm back and I just noticed I need to there we go chat room open okay so now we're going to inject our context Factory into here and to do that of course we're going to have to drop in a couple usings Entity framework core and we're going to use employees.data so that it knows where to read that employee class that we created earlier so this employees here we need to have that available and now you can see we don't have any squiggly lines on any of this stuff which is good because now we're going to display we'll first we're going to just display this create form so remember how we did the show create thing right so we say if show create so show creates true this is where we're going to put our crate form if it's not true we're just going to put this and uh actually we're not really going to do anything if we don't have a show create form so for now we can just put if show create is true display this stuff this one you're going to be really glad as a copy and paste because it is a whole bunch of lines but I'll explain it after I paste it boom there we go so we have a div class here a row we have first name last name email address department and Avatar each of those are bounds so we're using bind and we're binding it to new employee now remember how I said I'll Zoom this in a little bit remember I said we're creating that new employee object it's called new employee and it's just a blank employee object that's what we're binding to right here so we're binding everything to this new employee first name last name all of this is being bound to that new employee and then when we're ready to submit it we're ready to create a new employee we're going to call on click create new employee create new employee if you remember is right here and it's going to take that new employee that's bound to that form and just add a new one so let's see if it works for one um one thing we need to do let's see this is the form that we want to see right so if show creates true build the form but we want to actually show that form so we're going to have a button here our employees click create new employee we're going to put create new employee this button will always be up here no matter what but when we click it it's going to say on click oh I see I did something wrong here add a new employee et cetera Etc yeah I put the wrong stuff there so we do need that else button oops okay so if just to be clear if show create is true then we're showing a creation form where we can add a new employee if it's not true which is going to be most of the time right when you just first bring up the page then we want this and this one says add a new employee it's a button that's all it is is add a new employee it calls that show create form which if you remember show create form sets show create to true and creates that new employee object for us now it doesn't dispose of that so you know there could be some problems than Ryan if someone's like does show create to add a new employee decides not to goes and does something else it might get corrupted but for now I think this will work so we have add a new employee and then show the list now show the list of course is the listing of all employees that we haven't got to that part that's going to be the re the read portion of crud right now we're working on the create portion of crud so theoretically I should be able to push play we should just see a button here because uh show create should be false so we should see this button here that says add a new employee and show the list and then once we create that that should do show create form create a new employee object populate this form bind it fingers crossed fingers crossed we'll see and we're loading it up we did get a little uh information that we lacked or weight operators but we're going to add weight operators here it is so as we expected show the list is here which means when we have the read portion we're going to have the list of all of our employees when we click out a new employee this should show a new form and it does and these even though you can't see it these are all bound to the properties of that new employee object that we created so I'm going to create a new employee we're going to call them Lloyd I'm not spelled Christmas Lloyd at pluralsight.com Department he is our new devarell Avatar no we got those avatars from the uh actually we can just grab this Nimble text we got these avatars here from Robo hash so we're just going to create uh we're just going to copy somebody else's avatar for Lloyd for now uh where were we over here now if I submit then this form should disappear it should go back to the listing and then we should see Lloyd Christmas as our latest addition to the employees database there we go so the forms closed it says show the list but we need to prove it we don't really know if Lloyd has been uh inserted here as a new person and I need to check something really quick here because I just got a message about it something about the YouTube chat okay perfect so here we go show the list now we need to prove it right so let's stop the application let's open up our database again here's our list of all our people and look at that right at the bottom we have Lloyd pluralsight.com devrel Lloyd Christmas so that's the first part so crud create read update delete we just did create just like that and we'll go back and look at the code again really quick this is all our all our display stuff you know that's a form these things are bound to uh bound to that new employee object we created and then this is all the code it takes to create a new uh record which is amazing this might seem like a lot but this is not a lot of code considering that this thing is going and transforming all that data putting it into SQL running the SQL executing the SQL blah blah blah all that's being done for us by Entity framework core we're just doing this I mean this is really the core of the code here some of the other code that we that we do is going to be a little bit more complex but not much more I mean this is pretty much our create read and update and delete is kind of all going to be similar now like I said this is different from a lot of the Blazer tutorials you'll see from Microsoft and from other folks out there because I'm doing everything in one I'm going to try to smartly do everything in one form that's the hope for this is that one form to rule them all it's just going to be index.razer and index.razer.cs that's it we're not going to have edit aspx and delete aspx all that stuff it's all going to be self-contained I'm going to put this on GitHub of course so you can go do it and on all hands on tech.com I'm going to have this full uh tutorial on how to do this so now we need to do the list we've got this in here so for the list we need to make a public nullable list up here I'm going to try to clean this up just a little bit here save and we can do here we can do a public list of employees all we need and as you can see the autocomplete knows pretty much what I want to do I don't actually want to create a new list but I want to have a publicly accessible property that's a list of employees and what this does we do want it to be nullable and what this does is uh exactly what it said there's a list of employee objects we're going to pull objects out of the database with Entity Framework put them into this list and then that list is automatically going to we're going to use Razer to parse it and this is where Blazer is cool this is one of the reasons I like Blazer so much is there's no JavaScript being written as you can see we haven't written any JavaScript yet there's no JavaScript being written there's no uh let's see there's like no JavaScript being written there's no uh different user interface things we have to do or literally using plain old class objects in c-sharp passing them all over the place and getting this cool display from it so this is why I like laser because this Blazer is rapid application development for websites like it's the definition of rapid application development we're going to build a crowd app here in a couple of hours so you can't say that about a lot of web application Frameworks like if you're doing something like react and then you're doing rust on the back end which I kind of want to do that on a stream at some point you're going to have to write all of these different things in react all of this stuff in Rust and Blazer you're doing it all in one space one IDE one language super easy two languages I should say it's c-sharp and Razer but but yeah it handles so much stuff for you so we want to do uh we're going to do a task called show employees let's do that so on initialization we can just put a little thing in here create we'll kind of separate the sections a little bit this will be our create section and I wanted to create a summary I don't really want to create a summary I just kind of wanted to put a some little dividers in here create now we're going to start the Reed portion of it and I put exclamation points on everything just like I always put my thumbs up all the time it's just that excitement right read can't just be read It's gotta be read so in a read we're going to do a see uh show employees so once again I'm going to copy and paste so you don't have to watch me type it out but then I'll explain what I'm copying and pasting uh employees here I think was supposed to be our employees because there we go okay so we have our employees that's a public list what we're doing we're calling that context again creating the ab the DB context asynchronously spinning it up if it's not null then it probably created successfully we don't actually know that but this is good enough for this the purposes of this application if the context isn't null then all we have to do here is we we just set we call the context employees to list async so that's all of them every employee just pull them all out and put them in a list asynchronously will await that we'll stuff it into our employees that's all we're doing it's primitive but you know it gets the job done so here in employees this amount of code right here is all we need now you can go here and do selects you can do different types of queries here um you can use Link find all all this there's a whole bunch of stuff you could do here besides just list async list async is just easy for this purpose to just dump all of those things into a single view basically which is what we need to go back to we need to go back to our view now instead of show the list we're going to say if our employees we're going to bind to that our employees and then once again this is the coolness of Blazer is the ability to bind your UI to plain old class objects and you have a ton of control over it for some reason the autocorrect is is killing me on this but if our employees is not an old because it might be and we're going to say count because it could be null but or it could be not null and screwed up but our employees count this is just kind of an extra yeah is greater than zero so that means we have at least one employee here in our list that's all we're looking for even if there's just one employee in the database we'll show it so as long as it's not null and as long as it has one employee in it and then we're going to create a table yes the good old-fashioned HTML table this is what they were designed for so people uh for the last 20 years maybe have been anti-tables including me you don't use tables for layout you don't use tables for mobile app building stuff you don't use use tables for data and that's what this is this is data so this is actually a legitimate use of tables it's the only legitimate use of tables in my opinion is to hold data you could also put all this into divs if you want especially if you're a CSS person CSS people love divs and spans I do too except I love tables to uh display data why this thing is uh messing up I don't know but we'll find out because this should not be throwing all these squigglies the div has no special meaning at all yeah I understand that but whatever if missing a closing character so maybe I have something in here that makes it think I guess I have to close the table probably but this this part here is only going to be drawn one time and so if you're not familiar with tables if you don't come from the old caveman days of tables um you open and close them so this is a table header where we're saying you know I even put in the table responsive for bootstrap but but you have a table then you have a table heading and that's just the first row of stuff in your table it's only drawn one time then you start the table body now in the table body we're going to have a set of table rows and then we'll close it out so for that we're going to do a for each and we're going to say for each VAR employee in employees or our employees our employees so for each employee that's in our list of employees do this that's what we're going to put in the right so we're gonna have the table header table row table row table row 101 of them and then we're going to close it up and I have copied that from the article so you don't have to watch me type it out here's what it looks like so for every single employee in there which is 101 we're going to go through a hundred and one times create a new table row we're going to bind each of the values of these table cells to the values that are in that employee instance so for each of these we create a new of our employee and it's a local object and we just say employee ID first name last name email department down here in Avatar we do something a little different the reason why is because this is a URL to an image so what we do is to say image source equals employee Avatar 50x50 and this you could pretend is like a badge photo for your employees basically and we could have taken these um because these came in as URLs we could have taken these and uh just did like some kind of pull for them like a w get or something and pulled them and stored them as binary in the database but I didn't really think that would be uh very useful for us to do at this point so we're going here we've got two empty Fields here now that is going to be for our edit and delete so we're we're doing create read update delete so to put in those buttons I just put in two Extra Spaces up here you can actually see that I have an edit and a delete header there which I probably should say action or something I don't know but for now this will work so this probably makes sense now and then we close it all out this also only runs one time because it's outside of the loop now there's there goes all our red squigglies thankfully our red squigglies are gone so here we go let's do a quick recap before we uh hit F5 we have show employees as a method show employees what it does is we're created a database context if it's not null we're just going to take all the employees as a list stuff them into our employees then we're binding to that here we draw once we say our employees Etc if it's not null and the count is more than one then let's draw a table let's Loop through all of those for each of the rows and then let's close it out now this should work so let's press F5 see if it builds and runs should oh but I don't see the employees because we need to call we need to call that show employees right and that method is yeah show employees we can just do this and that will actually fix our uninitialized async because we can say show create and then we can say await show employees okay now this should work so now we're going to call show employees which is going to populate that which then theoretically is going to mean that this is populated and it will show all of the stuff that we want it to show we'll see let's see there it is so now we can go up and my lights are malfunctioning so I love these lights they're pretty cool they got a little remote control but every once in a while something happens I don't know a cell phone or something sets It Off but every once in a while they'll go like super bright like that blind me anyway here is our read function so now create read done we can now read these we have a list we can even scroll down all the way to the bottom and see Lloyd Christmas who is our devrel that we just added to the team we can see all of these now of course we can do searching filtering Etc all that kind of stuff but for now we just want to be able to read this and we did successfully if we want to add a new employee we can add a new employee um it doesn't matter or we can go home which it looks like there we go we actually have to do a Refresh on that but we could do a cancel to reload that but yeah look at that all of our folks and we hire nothing but cool robots here at Acme widgets and these are all of their badge photos so you can clearly identify the robots as they're walking in the front door right cool I got bad jokes for days um so create read complete now we need to update so now we're going to throw a real wrench in this thing because remember how I said that we're doing this a little bit differently than we're doing other than a lot of the tutorials tell you to do it so we're not going to do a separate aspx page for every single one of these there are advantages to doing that for sure um and you can tie into some of the ASP functions and stuff to call those and you can do things with routing that uh that make it advantageous if that's what you want to do but I want to keep everything in this single component because I want it to be simple for the user I want the user to be able to do everything they can do on this one page in this one area and this one component so that's what I'm shooting for here now to do that we need to go to update and I guess I could rearrange these right so that create is first really Hammer homeless crud thing create us first we have two methods to create we have one method for read I've not checked the chat for a while but it looks like yeah looks like okay cool no new chats thank you everybody for visiting us looks like we have over 60 people on LinkedIn watching right now which is awesome we have 14 people on Twitch very cool but twitch is Twitch is where we go but for some reason I did get uh a little error message here about buffering so that's what I'm making sure that yeah okay well somebody will let me know if it doesn't if the video doesn't show up right let me know in chat so we have create read next we all know is update update yay so an update we're gonna have to put in another couple of flags so we're in index.razer.cs this is the code behind we're kind of starting we're kind of going backwards instead of doing uh razor we're doing um instead of doing the Razer display first we're doing the back end first then the display we need to create a couple of uh Flags in here we're going to do show show create we already did show create we're going to do okay edit record so this is very similar instead of show create or below show create we'll do public pool edit record this is going to be the same thing as show create with show create if it's true shows a creation form if edit record is true I mean I probably should call it show edit I guess that would make sense but um let's see just for consistency we'll say show edit and that means that the edit page is showing so for here this is our first initialized async on here create read or yeah down here whoops down here we're going to have a method um we also need to create a new employee so what we did when when we created a new employee we created a new instance of the employee class and that object was bound to the form the form values are put in they're bound to that object then we send that object off to Entity framework or super easy super clean super sweet update very similar except that we are going to pull data from the database into an instance of the employee object to keep temporarily bind that to the form then when people change things on the form we'll send it back to Entity framework core to update so that may not make a lot of sense right now but it will when we're done so in here this is going to be another one and I'll put it below here because that kind of makes sense and this one's employee to update oh this one's not nullable let's make it nullable just like our employee updates nullable everything's nullable just in case something doesn't go our way right so we have our new employee employee to update down here in update we're going to do a thing called uh show edit form so this one I'm going to again copy and paste and then we're going to see something a little different in this task show edit form we're actually passing in the employee so our employee is going to be the employee that we're editing so when we click on edit we don't want a bunch of blank Fields right um if we're going to like edit first name last name we need to have those populated so we're going to go when someone wants to click to show the edit form we're going to show the edit form and we're going to populate it with the data from the employee that they're selecting to edit okay that makes sense we'll just uh we'll just dump this stuff in so we're going to create a new context again okay the employee to update we want to get the latest and greatest information for them so from here um this is going to be our employee dot ID there we go so what we're going to do is make sure that we have the latest and greatest out of the database so the reason I'm doing this is that let's say your user loads up the database in the morning right they load up the employee page in the morning um and Jeff wants their name changed to Jeffrey and so somebody else in another department also loaded up that same thing they changed Jeff to Jeffrey at 9 00 a.m but you haven't gone back to your screen since noon so it still says Jeff in the database that or in the data that you're looking at on your form screen so then you go to edit something else about Jeff's record it's going to have old data so that's the only reason I do this we pass in the employee that we want to edit but we don't actually use the data that's on the screen we pull the actual data from the database so that we have the very latest in information from the database that makes sense but we do use that employee ID from that employee but nothing else and then we populate employee to update which is what we created earlier when we create this temporary object called employee to update here we're going to say it is context first or default where ID equals our employee.id that should only bring up one person in this case Jeff was the the one that I used now we remember how we said we have an editing ID we need to create something for that so we're going to set a couple more Flags here we have show show edit we need to select show edit is true if we're doing this so we're going to say show edit is true now this will make a little bit more sense here we're doing an edit record up here I think we did public pool but I did not do the edit record okay um let's see check my notes Here records true editing ID we need to add in an editing ID so we're going to say public int editing ID this is the ID of the person we're editing right now why this is important is because we're going to take it's going to iterate through those rows right it's going to iterate 101 times in our case we want to say no we want to show an edit form well if we do that we're going to show an edit form for every single row we want the editing ID to be specified so we say no only for ID equals whatever the person's ID is that's the only time we want to show the edit form everybody else just has a regular form so editing ID is once again going to be our employee.id so if we're working on employee number one this task to just this just shows the edit form this doesn't actually do any of the editing yet but this task we'll show an edit form for the person if they're IDs seven then it's going to go and it's going to get their most updated most recent database information for employee number seven it's going to show that edit form and then editing ID is going to be number seven that way when it Loops back through the list it says oh this is id7 this one's being edited let's put in some fields to edit if that makes sense if that doesn't make sense feel free to Heckle me in the chat and uh hopefully I can clear up any questions you might have about that so we've got our editing ID our employee let's see show form just checking my notes Here make sure I got everything for the show edit form okay and then we're going to do the actual update so it's going to be in two steps you're going to click on the edit button it's going to edit that in employee's information and then you're going to click save and that's where this comes in update employee is going to be what happens when you save it actually not sure if my notes are correct on this one but that's okay we're going to work through it here we're going to create the create the DB context again I like to open and close the DB context so I like to inject it in and then have uh have the injection handle the opening and closing but I like to open it every single time it'll dispose on its own hopefully most of the time once the method completes but I like to just call it and and have it be open but I don't like to open it at the very beginning like at the top of the class and have it globally open for all of them because I've seen some issues with that in the past basically I'm just trying to kind of isolate these and keep them keep them good so open this up if context is not null we don't want to try to do stuff if we don't have a context now remember this employee to update this one right here that we just we just stuffed a bunch of data into it maybe somebody changed something on the form so this employee updates where our our latest and greatest best information is we're just going to say if that isn't null because for some reason it might be null and if it is then this whole thing isn't going to work we'll crash it and break it this way we're just going to kind of quietly shut it down but we'll call the context we'll go to employees we'll call update we're going to pass in this employee to update Entity framework is going to look at that ID F7 we used as an example right it's going to look at that ID and it's going to say oh this is idx let's update it with all of this other information now if you change the ID it's going to break it so don't do that but we're not going to make it so you can change the ID anyway hopefully but this is how easy it is using Entity framework core this is one of the reasons like like I've been talking about on here been kind of a a sales person for this technology but one of the reasons I love Blazer is this the data binding is my favorite thing ever how you can bind data to front-end components and do all this stuff with C sharp plain old class objects and I love Entity framework for the same reason you can do all of this wild stuff just passing around c-sharp objects so as long as you know how to build a c-sharp object you know how to do all of this stuff eventually if you're following along and learning with me so very great good stuff I love it then we need to of course save changes async and then uh there's a flag I feel like there's a flag update employee yeah there might be a flag that I need to set here show edit false yeah actually the intellisense put it in there because that makes sense that show edit would be true up here when we're editing but after we've updated the employee we won't show edit to be false so perfect this will be our update employee now we need to go back to Razer now in Razer we have here if it's show create create the form we're out of that area now if employees is not null and the account is zero display this stuff so now we need to wrap our table a little bit differently because this is where we're going to switch out a standard table row with a table row with editing elements in it if that makes sense so we're going to say if we're not editing your record if well I think we called it edit record edit record now what did we call it something oh show at it if we're not showing an edit we're gonna do this so if show edit isn't called or if the show edit flag isn't set to true then doesn't matter does it exactly the same as it did before it just a whole bunch of rows but if show edit is true then we're going to do something way different we're going to add a button for our edit field remember edit is this one so we're going to add this button let's take a look at this button really quick before I don't want to just dump it in here not say anything here we're creating an anonymous function on click we're going to create an anonymous function shows edit form with employee where does this employee come from it actually comes from VAR employee and our employees so we're doing that Loop through and this is what I was talking about uh before that um do we have this Loop through because this employee class that we're passing in here the only thing in there that's guaranteed to be the same is that ID everything else could have been changed on the back end after it was loaded up so we're doing a show edit form and we're passing in that employee so we can grab that employee ID and this one will need to be yeah in that row so when we click the edit button it's going to say show edit form and it's going to toss in the employee that's associated with that particular edit button if that makes sense now down here it's a little bit different so if we are editing record we need to say closing bracket if statement so if we're not showing edit we need to do this and then we're going to do an employee to update thing yeah if employee to update Okay so here again I'm copying and pasting if employee to update and that's that one that's that property it's Plano class object and it's a property that we inserted in on the back end that says this is the employee to update when you click show edit form it populates that employee to update with the freshest info out of the database so if it's not null and if its ID matches employee ID we want it to definitely match the employee ID on the row that you clicked on then we need to put in an edit form and it looks like I need to grab this edit form out of here so that you don't have to sit and watch me do this let's see I do have a let's see do you have Visual Studio code I can grab it out of there notes in here because uh you don't want to sit and watch me uh type all that stuff in index razor okay so if if it's not editing an if employee to update yeah okay so that's right then we're going to show this boom Troll cake troll d format that a little bit okay so if somebody clicks show edit so we have the list of rows we have the show edit button and somebody clicks edit that's going to say show edit form and it's going to redraw when it redraws it's going to say you know we've sent that employee that we want to update in that ID it populates employee to update so we say if employee to updates not null well it's not going to be null because it's going to it's going to have data and the ID is equal to that employee ID then we show this which as you can see is a bunch of input fields so as I said we don't want to update the ID ever so we're just going to display the ID as if it were any other row but then we have input ID a first name last name email Department Avatar all of these are bound to that employee to update so as soon as they hit the edit button they're looking at the freshest newest latest and greatest uh record and then they'll be able to change it because these are bound it's bound to these input fields and change anything you want and then on click we just say update employee and save it and it's good to go now if it's one of the other ones then we just want to draw this row again so unfortunately this is some duplicated code I've been kind of thinking through it different ways I can do it um and one of the things I can do here is push this off into a a separate component but we're not going to do that today because we're just we're going to try to to get through this part but for now we're duplicating this code and we're saying if it's not the employee ID that we want to update then just draw a regular old uh row so I think that's it now I think we can run it and try it I think we can update stuff F5 it's always it's always the anxiety with the F5 right never goes away and we're loading up and loading loading loading taking a little while there we go okay now we have the setup button we didn't have the edit button before right so let's click the edit button and exception has occurred let's find out what it is I cannot use of a dis access a disposed content instance so I probably didn't load in no I did load it context async update employee that I'm not sure why context is not null wait yeah that doesn't make a lot of sense let's try it again try to read that error message a little a little closer because I am maybe I'm overlapping the context when I shouldn't be edit says cannot access a disposed context instance a common cause is disposing a context instance that was resolved later trying to use the same one elsewhere in your application this may occur if you're calling dispose on the context sentence wrapping it and using statement which we're not doing any using statements for this which generally I do but I wanted to keep this as simple as possible so show edit form does this context Maybe update employee doesn't actually need a new context and we can use that same context instance let's just try it nope all right so maybe we need to dispose this thing I don't know let's see it's looking through my notes doesn't appear to be something that uh that I ran into when I originally put this thing together so one thing we can do is uh we can just dispose it after this and see if that helps contacts template update oh this one I didn't wrap and I probably should do the if context does not null around this one maybe that's the problem if the context is not null that could be a problem that I didn't wrap it here let's find out nope so show edit form it's having the problem immediately after this so we gotta if context is not null Let's uh do a dispose and I've got it copied here after show employees oh it is being disposed so maybe we'll let the let the injection handler do the ex disposing yep and that's what we needed to do so go back and ignore where I said to dispose of it we're going to let we're going to let the handler do all that stuff for us so it's even less code than before which is good so now remember what I was saying if you press this it's going to set that show edit flag and Bam then all of a sudden it's a new row but it's only for row number one right it's kind of like add a new employee only works for employees so we're going to edit krishna's here and we'll just uh replace it with test and test and test and test and test now it's all tests click save now every record is test and if we go in here browse table you can see it's been updated so now we've done create C read update now we just got to do delete so 75 percent of the way through the crud operations as they call them so whenever you hear someone say something about crud you know it's always create read update and delete um oops I got a message here uh okay I'll deal with that later um so whenever you hear someone say crud right and they talk about crud Ops crud operations it's create read update delete that's all it means so we have done create read and update so far we can update any of these that we want to very easily now we need to put in that delete button and then we're done then we've got total crud here because we're able to add a new employee right we added that one we could still do that and say Jim Bob jim.com test test submit we've got a new record jimmy.com test Etc now we need to be able to delete it so we can close our read we can close our update which also has two methods and the only reason Reed has one method is because it just reads right just one time but both the create and update have two methods because they have to show a form then interact with that form blah blah blah now delete is pretty easy so I'm going through my notes Here make sure I don't miss anything I don't think I missed anything here we just need to create a task to delete employees so I'm not going to do like a confirmation screen or anything like that we're just going to delete it now here's a note of one of the things that I probably should have done when we started this is a lot of times I put a flag in there active inactive so especially if this were an employee database in real life we would want active and inactive rather than deleting the record out of the database because we want to keep that record so we can go back and look at it later so we could set it to inactive which is essentially soft deleting it we're not going to do that today I should have done that in the beginning but now we're at delete which doesn't it doesn't need to be all caps but now we're at delete and this is going to be an actual delete it's going to remove the record out of the database it never existed this person never worked here however a soft Elite is better now here within the curly braces we have delete employee we're going to once again create that DB context if it's not null I love the intellisense lately it's been doing doing great and we'll go through here now delete employee you'll notice we're passing in an employee again and the reason we're doing that is just for that ID mostly but we want to pass in the employee that's associated with the delete button that we're hitting so if you hit delete on Row 4 it needs to be employee 4 that goes in here so if employee is not null then we're just going to do context employees remove our employee right um like I said nosql no wild transaction things just uh employees dot remove and then context save changes async that's it um which is cool and then of course we need to show the employees again because we have that show employees so we can just put a weight show employees that way when you delete it it'll automatically refresh the list for us um I don't remember if we did that after the show create did we or after create new employee yeah we we should do that await show employees so when we create a new employee it does the same thing just want to show it so there it is delete employee take a good look once again this is why I love Entity framework core this is why I love Blazer because this stuff is so simple we're just passing around plain old class objects we're just taking our employee that we want to remove we're passing them into employees.remove literally removing them save changes async now if we're doing a soft delete like I mentioned then we do one of these updates again right but we'd update with that field being changed but we're actually deleting it we're blowing it out we're clearing it out of here so we're just about done with our crud operations since we have delete here it is now we need to display so to do that we need to go to that empty TD and put in this button and I will copy and paste the button from my notes once again so you don't have to see me type and look at that button doesn't it look familiar it looks just like the the edit button to show the edit form but instead we're deleting an employee we're still passing the employee now the reason why like on here it says unclick unclick update employee that's perfectly fine if you are um just calling a method that doesn't have any parameters um then that's fine but if you have parameters and those parameters are bound to Razer variables then you have to do this uh on click where you create an anonymous method delete employee with the employee that you want to delete and yeah it's that's that's all of it right there now because we duplicated our code which is uh something that I will address at a later stream because we're almost out of time but since we duplicated our code we have to put it up here too it's that delete button should always be available now save and I need to check it looks like I have a meeting coming up and so I need to make sure that I'm not late for that meeting oh that is what the message is about okay so where's our delete button we don't have one I need to put it up here too however we're going to take it out of here so what I did is I put this into our edit form we don't want to do that we'll just leave that blank so our delete button is in here if there's no show edit there's no edits being shown then we're just drawing that out we we draw out a delete button or if somebody's editing something we can also put the delete button down here though we probably shouldn't even have it there either really but it probably should just be on that that main page now that I think about it I don't want people trying to do too many things at once so let's see what this one looks like this should have a delete button but if we edit there is no delete there's just that save okay perfect it looks like we've got to refresh that's another thing that I should probably fix in this at some point right so we have edit and delete we can add a new employee Let's uh just click it oh they're gone what about the one we deleted or the ad we added Jim earlier boom Jim's gone and like I said these are actual deletes so in here remember we have a well we didn't we didn't bring up gym where we could see Jim but we have tests now if we go back in here and we do another browse table which is basically select star you can see that we're now going from one to three so we're able to delete so we have create read update delete it's awesome it's fantastic this is all the code we'll go back over it really quick here if you look at it from a high level this is all the code in our front end this is why I wanted to do it this way like a lot of the the tutorials tell you to break it out into a ton of different pages and that's that's fine but look at that this is all in one page and that's all the code that's there our index razor we'll expand these it's a little bit more of course but not that much code man not that much code so you know as we're looking at this you think about it we're able to create read update and delete from a web interface on a web page to an actual database with this much code this is why I love this Razer this is why I decided to create this article and create this stream today to show people how cool it is to use the sqlite easy to use file based database I can publish this out to Azure websites it works perfectly fine but this is all the code we're writing here's all my front end code all of it every bit of it no wild JavaScript stuff this is all my backend code every bit of it and we're creating reading updating and deleting all of this stuff you know we're able to just come in and say oh I've got a new employee Susie at Acme widgets and Susie is in our engineering department Let's Pretend she has an avatar something that jpg right we go down here boom there's Susie Johnson oh Lloyd Christmas really messed up uh gotta get rid of Lloyd Christmas right delete like Christmas is gone boom boom Oh what about Kiefer Keepers decided that that their first name is Silly it should be Keith okay cool now it's Keith easy so we're able to create read update and delete today and once again as a reminder I like to post follow us on Twitter you're not following us you should follow us on Twitch the reason for that is that right now I'm streaming on LinkedIn and Twitter and YouTube and Etc et cetera et cetera but we don't always do that but we always stream on Twitch all of our events all of our live streams all of our cool stuff I'm here every Tuesday at uh this time uh 11 A.M Pacific Time 11 A.M Pacific time uh on Thursday David Neal does it he's building some JavaScript stuff
Info
Channel: Pluralsight
Views: 1,304
Rating: undefined out of 5
Keywords: blazor, sqlite, blazor development, asp.net, .net core, entity framework, ef core, entity framework core, entity framework tutorials
Id: bhVbEQWy0io
Channel Id: undefined
Length: 109min 51sec (6591 seconds)
Published: Tue Feb 07 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.