Part 20 Table Per Type TPT inheritance in entity framework

preview_player
Показать описание
Text version of the video

Healthy diet is very important both for the body and mind. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking our YouTube channel. Hope you can help.

Slides

Entity Framework - All Text Articles

Entity Framework - All Slides

Entity Framework Playlist

Dot Net, SQL, Angular, JavaScript, jQuery and Bootstrap complete courses

In this video we will discuss implementing Table Per Type (TPT) inheritance in entity framework with database first approach. In TPT inheritance one database table per type is used to store data for the respective entity types in the inheritance hierarchy. This means there is no problem of de-normalized tables.

In Parts 18 and 19 of Entity Framework tutorial we discussed how inheritance hierarchy can be represented using Table Per Hierarchy (TPH). With TPH one database table is used to store data of all the entity types in the inheritance hierarchy. The downside of this is that we have a denormalized table and some columns will have NULL values depending on the type of the derived object being saved to the database table.
Рекомендации по теме
Комментарии
Автор

Hats off to you sir for your teaching, patience n uploading the videos to all....

thirupathinampelli
Автор

Venkat sir, all your work is greatly appreciated. We are learning so many things from this. Just one correction in this..if someone like me also tried to test an insert permanent employee in this example also, it will throw an error. This is because entity framework by default treats all the tables without a primary key as views. and here the tables permanent employees and contract employees doesnt have a primary key and hence insertion would throw an error. At 3:24 in this video we can notice this. Correct this script to make employee id as both primary and foreign key in both permanent and contract tables and then execute the insert functionality to see the actual results.

vijjuinhyd
Автор

Did the same configuration (it's also on MSDN pages) but I'm getting an error: Error 159: EntityType has no key defined. Define the key for this

Why should I define a key for the class that inherits it from the base class already?

fernandofiauxdemoraes
Автор

Getting error as
Unable to cast object of type 'WebApplication6.Employee' to type While selecting all employees

SoftwareDeveloperAspNet
Автор

Why do we want inheritance relationship instead of foreign key?

amitgovil