GithubHelp home page GithubHelp logo

phanxuanquang / asp.net-core-web-api-with-orm Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 56 KB

The template to setup a backend server using Entity Framework and XML Documentation, bypassing CORS policies, restructuring API response format, and customizing message for standard HTTP status codes

C# 100.00%
api asp-net-core backend cors csharp dotnet entity-framework entity-framework-core mssql npgsql orm postgresql sql sqlite sqlserver swagger template visual-studio

asp.net-core-web-api-with-orm's Introduction

image This project template tailored for backend development using C# .NET. Whether you're a newcomer to backend development or an experienced developer looking for a streamlined setup, this template provides a solid foundation to kickstart your project.

Now that you have a solid foundation, feel free to explore and extend the template to suit your project requirements. Whether you're building a small-scale application or a large-scale enterprise solution, this template provides a robust starting point for your backend development journey.

๐ŸŽฏ Target Audience:

  • Newcomers to Backend Development: Get up and running quickly with a project that's ready to run out of the box.
  • C# .NET Developers: Utilize the latest features of .NET 8 for efficient backend development.
  • Database Enthusiasts: Connect seamlessly to popular SQL databases like SQL Server, PostgreSQL, and SQLite.
  • API Development with ORM: Implement Object-Relational Mapping (ORM) techniques effortlessly using Entity Framework.
  • Minimal Configuration: Minimize setup time and focus on coding with pre-configured settings.

๐Ÿš€ Pre-configured features

  • Standardized connection strings for SQL databases ensure smooth integration.
  • Automatic database connection checks before server initialization.
  • CORS policies are pre-configured to prevent blocking when accessing APIs from different origins.
  • Integrated Swagger UI with pre-configured XML documentation for clear API documentation and exploration.
  • Filters in place to structure API responses and provide meaningful error messages, enhancing client-side handling.
  • Newtonsoft.Json NuGet package is included for efficient JSON serialization and deserialization.
  • Provision of examples for standard SQL table schema creation, model definition, and DbContext declaration.

โš’๏ธ Prerequisites

๐Ÿ“š Usage Guidance

In this guidance, I take SQL server as the example for database connection.

Step 1: Download and install

  • Download the template HERE but do not extract the package after downloading
  • Place the template in the following folder. The folder name may vary depending on your Visual Studio version.
...\Document\Visual Studio 2022\Templates\ProjectTemplates

image

Step 2: Setup connection with database

  • In the appsettings.json file, input information for the connection string. You only need to input the information for the database that you want to use. image
  • In the DatabaseConnectionChecking.cs file, input the type of your SQL database. Specify your SQL database type by modifying SqlServer to the desired database (SqlServer, Sqlite, or Npgsql). image
  • In the NuGet Package Manager, find and install the NuGet package coresponding to your database type which is mentioned in Program.cs file image
  • In the Program.cs file, enable only your database type by removing the Comment remark image

Step 3: Make it yours

  • Create the models and controllers as needed image
  • Register your models in the ApiDbContext.cs file image
  • Optionally apply the provided filters to your controller classes. image

4. Additional Notes:

  • The template is pre-configured for SQL Server; consider PostgreSQL for large-scale projects with extensive datasets and SQLite for smaller projects with simpler database schemas.
  • Tailor the template to your specific project requirements and database preferences.

asp.net-core-web-api-with-orm's People

Contributors

phanxuanquang 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.