Assalamualaykum Wr Br..:)
Today we are going to discuss Entity Framework Code First approach with a simple console application demonstrating School activities with two classes named as Student & Standard.
As we know student have attributes like StudentId, Name, Standard, Age & Date Of Birth hence we are going to create properties with same name in class Student.
Similarly, Standard class do have properties like StandardId, StandardName but this class can have multiple students hence we are using ICollections of type Student as shown below:
Now I would create a new class with SchoolDBContext name where DBContext is mandatory for flexible default operations with built in libraries of Entity Framework. This DBContext have dataset hence its return type would be Dbset and its properties are classes with s appended atlast with name as shown below:
Finally it is required to call the DBContext class in main method as shown below:
With this Execution of program, Entity Framework creates the New database with tables as designed with classes as shown below:
With this it is observed that based on the code design DB is being generated hence it is regarded as Code First Approach.
Thats it for today..:Jazakallah khair