.NET Core Web API Microservice with SQL Server Entity Framework Core

preview_player
Показать описание
In this video we explains how to create a .NET Core Web API Microservice with SQL Server Entity Framework Core.

The Microservice Architecture has become hugely popular in recent years. Experts predict that all New Apps Will Feature Microservice Architectures that improve the ability to design, debug, update, and leverage third-party code. Microservice architecture will continue to help businesses reduce downtime, optimize resources, and decrease infrastructure costs.

This video is also an ASP.Net core web API tutorial for beginners as we have completely included the ASP.Net Core API development. It can also be considered as a Entity Framework Core Tutorial.

In this .NET Docker tutorial, you'll learn how to manage more than one container and communicate between them when using Container Tools in Visual Studio. Managing multiple containers requires container orchestration and requires an orchestrator such as Docker Compose, Kubernetes, or Service Fabric. Here, we'll use Docker Compose. Docker Compose is great for local debugging and testing in the course of the development cycle. This is a very important video as it covers a major part of Docker .Net Core Microservices.

Visual Studio provides the options to easily develop applications with Docker Support, Debug with Docker [Docker .Net Core Debug], and Deploy the Docker Container [Deploy .Net Core to Docker].

We are using the Official container image for Microsoft SQL Server on Linux for Docker Engine [SQL Server Docker]. We'll use this docker image for creating a container for SQL Server Database. Then the .Net Core application container can connect to the database container for read-write operations.

We are making use of Entity Framework Core (Entity Framework Core Tutorial) for SQL Server Database operations.
Entity Framework Core is the new version of Entity Framework after EF 6.x. It is open-source, lightweight, extensible and a cross-platform version of Entity Framework data access technology. Entity Framework is an Object/Relational Mapping (O/RM) framework. It is an enhancement to ADO.NET that gives developers an automated mechanism for accessing & storing the data in the database. EF Core is intended to be used with .NET Core applications. However, it can also be used with standard .NET 4.5+ framework based applications.

Visual Studio provides a consistent way to develop Docker containers and validate your application locally. You can run and debug your apps in Linux or Windows containers running on your local Windows desktop with Docker installed, and you don't have to restart the container each time you make a code change.

You can view what's going on inside the containers that host your app by using the Containers window. If you're used to using the command prompt to run Docker commands to view and diagnose what's going on with your containers, this window provides a more convenient way to monitor your containers without leaving the Visual Studio IDE.

What is Docker Compose?
Docker Compose is a tool for defining and running multi-container Docker applications. With Compose, you use a YAML file to configure your application’s services. Then, with a single command, you create and start all the services from your configuration.

Docker .Net Core:
.NET Core can easily run in a Docker container. Containers provide a lightweight way to isolate your application from the rest of the host system, sharing just the kernel, and using resources given to your application. Learn how to use docker for .Net Core and deploy .Net Core to Docker.

.NET Core images
Official .NET Core Docker images are published to the Microsoft Container Registry (MCR) and are discoverable at the Microsoft .NET Core Docker Hub repository. Each repository contains images for different combinations of the .NET (SDK or Runtime) and OS that you can use.
Microsoft provides images that are tailored for specific scenarios. For example, the ASP.NET Core repository provides images that are built for running ASP.NET Core apps in production.

The tools included in Visual Studio for developing with Docker containers [.Net Core Docker Container] are easy to use, and greatly simplify building, debugging, and deployment for containerized applications. You can work with a container for a single project, or use container orchestration with Docker Compose or Service Fabric to work with multiple services in containers.

Docker support in Visual Studio:
Docker support is available for ASP.NET projects, ASP.NET Core projects, and .NET Core and .NET Framework console projects.

Video Chapters:
0:00 - Video Summary
1:08 - Project Setup
3:38 - ASP.Net Core Web API Development
9:15 - API Testing with Postman
13:49 - Container Orchestration Support
Рекомендации по теме
Комментарии
Автор

Excellent. Pitched perfectly. I am an experienced developer. I don't need a lot of obvious explanations and you have got this just right. There are other videos which would take 90 minutes to explain what you just showed in 20. Good stuff. Keep it up. Subscribed and liked

SiegfriedFarnonMRCVS
Автор

Great tutorial to learn from ground level, you please share Git repo.

akashgupta
Автор

Great Video! I have one question though. Is it safe to use the sa user for every microservice, or would you create a new db login and user for each microservice?

TheLilRussia
Автор

Good Video, but I can't connect Database when following your codes. Would you help me?

naveenranjitkar
Автор

when creating docker. when they ask target OS. should i choose windows because im using windows or i still choose linux anyway?

hermanpranoto
Автор

Hello. Help pls. Where I can find a correct user ID? I have a problem in connection string, so I want you to desribe what every property means.

crashgames
Автор

Hi, great tutorial but I encountered this error when I cloned your repo

" (0x80131904): Login failed for user 'sa'.
at owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection) "

I initially followed your tutorial & did the same thing & still encountered that error. Can you assist?

YakubuAzure
Автор

Hi, If we have multiple WebApis (eg: 2 Api), then should we create 2 Docker container for each Api? please confirm

pks
Автор

Hello Bro
When I run docker-Compose. So I have received this type of error: The "PrepareForLaunch" task failed unexpectedly.
Please can you solve this query

abdulmussavir
Автор

This wasn't really helpful as it doesn't seem like you are explaining the micro concept. Help me understand what the correct concept of microservices are please.

First create 2 Api's.. each with its own container. Then:

1. Each Api to have it's own DB and the APIs can then communicate with each other to manage databases. This means each API can use EFCore to build the DBs code first.
2. Both Api's communicate with the same DB. Which Api will then manage the DB code first generation? To me this then breaks the concept of microservices as the 2 APIs cannot live in isolation.. the one is always dependent on the other?

So my question is.. Should each Api then have it's OWN db in order for it to be a microservice? If not, and you use Code First, it feels like everything gets very messy.

Zizzy
Автор

Could you please suggest me to fix this issue.

fail:
An error occurred using the connection to database 'master' on server 'customerdb'.
A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: TCP Provider, error: 35 - An internal exception was caught)
fail:
An error occurred using the connection to database 'dms_customer' on server 'customerdb'.
fail:
An exception occurred in the database while saving changes for context type
(0x80131904): A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: TCP Provider, error: 35 - An internal exception was caught)
---> The remote certificate was rejected by the provided

JirayuSutawong-wq