Using Entity Framework Core with Legacy Databases
1h 31mIntermediate2018-09-06
Authors

Richard Goforth
Software Architect and Consultant
Course details
Not every development project starts from scratch. Often, you're rewriting applications to take advantage of different data sources, or to make connections to legacy data in more efficient ways. Entity Framework (EF) Core plays extremely well with existing databases, and it can generate some of the data-access code for you automatically. Using the practical techniques shown in this course, you can use EF Core with existing relational databases, and modify the generated code as necessary. Richard Goforth shows how to connect to a database, scaffold a model from it, and begin improving on that model. He uses shadow properties, concurrency tokens, and other techniques to best map a database to an application. No matter how untidy your tables and fields, EF Core will help you write clean, cross-platform code that is easy to maintain in the long run.
Learning objectives
Setting up your project
Connecting to a legacy database
Scaffolding an initial model and context
Improving the model
Adding concurrency tokens and timestamps
Modeling complex relationships
Working with non-Microsoft databases such as SQLite and PostgreSQL
Learning objectives
Setting up your project
Connecting to a legacy database
Scaffolding an initial model and context
Improving the model
Adding concurrency tokens and timestamps
Modeling complex relationships
Working with non-Microsoft databases such as SQLite and PostgreSQL
Skills covered
LINQEntity FrameworkSQLFull-Stack Web DevelopmentProjectWeb DevelopmentOpen SourceMicrosoft
Concepts
0. Introduction
- 01 - Welcome to Entity Framework Core
- 02 - What you need to know
- 03 - Platforms available to Entity Framework Core
- 04 - Why Entity Framework Core for an existing database
- 05 - When Entity Framework Core might not be a good choice
- 06 - Using the exercise files
1. Get Started with Entity Framework Core (on Your Legacy Database)
- 07 - Setting up your project
- 08 - Connecting to the database
- 09 - Scaffolding an initial model and context
- 10 - Choose your approach
- 11 - Understanding the generated context
- 12 - Migrations against an existing database
2. Improve the Model
- 13 - Why change the generated model
- 14 - Changing names
- 15 - Using shadow properties
- 16 - Generated properties and default values
- 17 - Using backing fields
- 18 - Adding and altering indexes
- 19 - Adding concurrency tokens and timestamps
3. Model Complex Relationships
- 20 - Creating an inheritance relationship
- 21 - Navigation properties
- 22 - Alternate keys and multicolumn keys
- 23 - Accessing computed columns
- 24 - Challenge - Product recall
- 25 - Solution - Product recall
4. Work with Non-Microsoft Databases
- 26 - Other database platforms
- 27 - Create a SQLite database
- 28 - Populate a SQLite database
- 29 - PostgreSQL on a Mac
- 30 - Other options
Conclusion
- 31 - Next Steps
Related courses
Related learn paths
- Getting Started as an ASP.NET Core Developer
- Getting Started as an ASP.NET Developer
- Prepare for the MTA: Software Development Fundamentals Exam (98-361)
- Become a Blockchain Developer
- Become a Java EE 7 Developer
- Working with Data: Engineering, Integration, and MLOps for AI
- Build an Ethereum Blockchain App
- Become an Android Mobile App Developer