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.
Why change the generated model
From the course: Using Entity Framework Core with Legacy Databases
Why change the generated model
- [Instructor] Now we have a functioning Entity Framework Model against our database, we know how to keep it updated, and we know how to use it to update the database. Isn't that all we need? It is, but we can do better. We wanna have code that is easy to read and maintain in the long term. To maximize the value of Entity Framework, there are changes that we can make to improve the way that the application interacts with the data. We could improve the names of tables and properties to semantically name the fields. We can hide things that don't matter to the application with shadow properties and backing fields. We can isolate specific database logic with things like concurrency tokens and generated columns. Often, additions to the model can be made to improve the code. But we don't want those additions in the database, just in the code. As an example, let's open up the Models folder and navigate to the Salesperson model. In the main program, we used the first name and last name…
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.
Contents
-
-
-
-
(Locked)
Why change the generated model2m 8s
-
(Locked)
Changing names1m 49s
-
(Locked)
Using shadow properties2m 23s
-
(Locked)
Generated properties and default values4m 34s
-
(Locked)
Using backing fields3m 35s
-
(Locked)
Adding and altering indexes3m 38s
-
(Locked)
Adding concurrency tokens and timestamps4m 8s
-
(Locked)
-
-
-