GithubHelp home page GithubHelp logo

dotnetcoreapitemplate's Introduction

ASP.NET Core WebApi template

This template can be used to bootstrap a working full-fledged ASP.NET Web Api project with a single CLI command (see below).

It contains what I consider to be best practices/patterns, such as CQRS, Mediator, Clean Architecture.

โญ Like it? Give a star

If you like this project, you learned something from it or you are using it in your applications, please press the star button. Thanks!

Motivation

I found implementations of similar samples/templates to often be overly complicated and over-engineered (IMO). This is an effort to create a more approachable, more maintainable solution that can be used as a starting point for the majority of real-world projects while, at the same time, striving to reach a sensible balance between flexibility and complexity.

Features

Usage

1. Bootstrap your project

Here are a couple of ways to bootstrap a new project starting from this template.

Cookiecutter template

Probably the best way to bootstrap this project, with just one command, but some dependencies are needed.

  1. Make sure Python is installed
  2. Install cookiecutter.
  3. Bootstrap initial project with the following command: cookiecutter gh:undrivendev/template-webapi-aspnet --checkout cookiecutter

GitHub template

You could use this project as a GitHub template and clone it in your personal account by using the Use this template green button on the top of the page.

Then you'd have to rename classes and namespaces.

2. Apply initial migration

When you have the project ready, it's time to create the initial migration using dotnet-ef (or if you use Rider, like me, you can try this plugin).

Here's an example command using the default solution name, if you changed it you would have to adapt it accordingly:

dotnet ef migrations add --project ./src/WebApiTemplate.Infrastructure/WebApiTemplate.Infrastructure.csproj --context AppDbContext --startup-project ./src/WebApiTemplate.Api/WebApiTemplate.Api.csproj InitialMigration

The above migration is applied automatically during startup in the dev environment.

3. Start the application

The default API endpoints should be testable from the Swagger UI.

Enjoy!

dotnetcoreapitemplate's People

Contributors

ekeneamah avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.