The Entity Framework Core Fluent API is used to configure the model classes. In this tutorial, we will learn the basics of Fluent API and learn how to use it to configure the model. The database is built using the model, which is known as Code First, The EF Core calculates the model by using the conventions and data annotation attributes. Both conventions and annotations do not cover all the functionalities. The Fluent API is another way to configure our domain classes. It is more flexible and provides developers with more power to configure the database.
EF Core Conventions or the default rules that you follow while creating the entity model. The EF Core uses these to infer and to configure the Database. It uses the information available in the POCO Classes to determine and infer the schema of the database that these classes are mapped to. For example, the table name, Column Name, Data Type, Primary keys are inferred from the Class name, property name & Property type by convention to build the database
In this article, we will learn how to use Entity Framework core with existing database or Database First approach. The Entity Framework only supports code first & Database first approach. In Database First, we use scaffolding to create the entities from the existing database. This process is also called as the Reverse engineer the existing database. Once the entity classes are created both databases first & code first approach works in the same way Database First Approach
In this tutorial, we look at What is Entity Framework Migration is and how to create migrations. We will build a simple console application and create two models. We will use the add-migration command to create the migration and then use the update-database command to create the database. Next, we will update the model and create another migration and update the database. Then we will revert the migration from the database and remove the migration. Finally, we will also see how to generate SQL Scripts containing the migration commands
In this article, we look at DBContext. We also look at how to create a DBContext class in our ASP.NET Core application. Next, we will show you how to register DBContext for Dependency Injection. Later we will take a look at how to configure DBContext using DbContextOptions & DbContextOptionsBuilder. Finally, we will look at various functions performed by the DBContext