Creating an Application from Scratch using .NET Core and Angular 

Creating an Application from Scratch using .NET Core and Angular 

In this article we are going to see how to create the Models (our entities) in the domain layer, create the migrations and the database using Entity Framework Core.

In this article we are going to see how to create the Models (our entities) in the domain layer, create the migrations and the database using Entity Framework Core, and we are also going to use the Fluent API for mapping our entities to the database.

Domain layer

In the Domain project, let’s create the ‘Models’ folder, and also create our entities: Book, Category and Entity classes:

Image for post

Those entities that we are going to create, will become the tables in the database. So let’s start implementing an abstract class for ‘Entity’, which will contain an Id of type ‘int’:

namespace BookStore.Domain.Models
    {
        public abstract class Entity
        {
            public int Id { get; set; }
        }
    }
view raw
Entity.cs hosted with ❤ by GitHub

This is an abstract class because this class cannot be instantiated, it only can bee inherited. All other entities will inherit from this class. The difference between an abstract class and an interface, is that an abstract class can have logic, and the interface it’s just a contract which specifies what are the methods or properties.

We are going to have two entities, that will be two tables in the database, the Book and the Category. Let’s keep in mind that one book must have one category, and a category can belong to many books.

api dotnet-core full-stack-developer clean-code visual-studio visual studio code

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Hire Full Stack Developers

If you are looking for a full-stack mobile developer for your web or mobile app development needs? **[Hire Full Stack Developers](https://hourlydeveloper.io/hire-full-stack-developer/ "Hire Full Stack Developers")** to develop any type of web...

Advantages of hiring a full stack developer

Interested in pursuing a career in Full Stack? Join Full Stack Developer Course in Chennai to become an expert in front and back-end technologies. Talk to our counselor for further queries.

Hire Full Stack Developer India

Do you want to get a web application that can meet your business requirements successfully? We love to work with startups and enterprises to solve their business problems using our full-stack technology competencies. Our expertise in agile and...

How to Develop an ASP.NET Core Application Using Visual Studio Code

Visual Studio Code (VS Code) is a free, cross-platform, and lightweight source-code editor developed by Microsoft for Windows, Linux, and Mac operating systems. It is a source-code editor while Visual Studio is an IDE (integrated development environment). VS Code supports development operations such

Development Containers in Education with Visual Studio Code

Development Containers in Education with Visual Studio Code