From the course: Using Entity Framework Core with Legacy Databases
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Accessing computed columns
From the course: Using Entity Framework Core with Legacy Databases
Accessing computed columns
- [Instructor] Computed columns often exist as part of databases to simplify common queries or to make some data more easily viewable. In our database we have a computed column on the customer. Let's start by navigating to the context in the Models folder and viewing the computed column there. We can see that the computed column is defined here. In an earlier video, we talked about value generation. The generation here is set to add or update implicitly because this is a computed column. This is the SQL statement that is the columns definition. Let's move our main program and use this computed column. We'll start by removing the code from previous videos. Let's get the third customer and write the computed column full name out to the console window. The column is CmpLastFirst, and run the application. We can see that this customer's name is Ernest Ramos. Let's change the first name of the customer, we'll call him Ernie. Next, we'll copy the line above to write the computer column back…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.