Building a database using Entity Framework (EF) Code First Migrations
Entity Framework (EF) is Microsoft's object-relational mapper (ORM) for .NET, which allows developers to easily work with relational data inside their applications using domain objects. Instead of manually writing data access layers to read/write and parse data, as you would by using native ADO.NET, using an ORM saves time and effort. When we use EF in our projects, we have a number of different options to create our database and entities:
- Database-First: With this technique, we can create our database (or use an existing database) in a tool such as SQL Management Studio using SQL scripts or the designer. In Visual Studio, we can create an ADO.NET Entity Data Model (EDM) to create entities and map them to existing tables.
- Model-First: This is similar to Database-First, where we use an EDM to design our entities, but then, we let EF to create our database from it.
- Code First: Using the Code First approach, we get more...