DbManager.EFCore 2.0.0

dotnet add package DbManager.EFCore --version 2.0.0
NuGet\Install-Package DbManager.EFCore -Version 2.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DbManager.EFCore" Version="2.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add DbManager.EFCore --version 2.0.0
#r "nuget: DbManager.EFCore, 2.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install DbManager.EFCore as a Cake Addin
#addin nuget:?package=DbManager.EFCore&version=2.0.0

// Install DbManager.EFCore as a Cake Tool
#tool nuget:?package=DbManager.EFCore&version=2.0.0

Simplify Your .NET Project with DbManager

DbManager is a powerful package that simplifies the integration of CRUD (Create, Read, Update, Delete) operations in your .NET projects. It seamlessly supports various database systems like MS SQL Server, MySQL, and allows you to choose between Entity Framework or Dapper as your preferred data access technology.

Getting Started

Integrating DbManager into your project is as easy as 1-2-3-4:

Step 1: Add Project Reference

Begin by adding DbManager to your solution as a project reference.

  • .Net CLI

    dotnet add package DbManager.EFCore
    
  • Package Manager

    Install-Package DbManager.EFCore
    

Step 2: Register Database Context

In your Program.cs file, register the AppDbContext class of DbManager library:

var builder = WebApplication.CreateBuilder(args);

// Use DbManager -> AppDbContext to register DbContext for your project.
builder.Services.AddDbContext<AppDbContext>();

var app = builder.Build();

Step 3: Configure Connection Strings

In your appsettings.json file, configure the connection strings based on your database provider and entities project:

For MS SQL Server:

{
  "DatabaseProvider": "SqlServer", 
  "EntitiesAssemblyName": "Demo.Db", // Assembly name where you have your Entity classes
  "ConnectionStrings": {
     "DefaultConnection": "your_sql_server_connection_string_here"
  }
}

For MySQL:

{
  "DatabaseProvider": "MySql",
  "EntitiesAssemblyName": "Demo.Db",
  "ConnectionStrings": {
     "DefaultConnection": "your_mysql_connection_string_here"
  }
}

Step 5: Add entity class/classes

[Table("Students")]
public class Student
{
   [Key]
   public int Id { get; set; }
   public string Name { get; set; }
   public int RollNo { get; set; }
   public string Section { get; set; }
   public string BirthDate { get; set; }
   public string BloodGroup { get; set; }
}
  • You must mark your entity classes with [Table] annotation, otherwise "DbManager", will not be able to include them to the DbContext.

Step 4: Inject DbManager into Your Classes

Inject the AppDbContext class into your desired Controller, Business, or Repository class. For example, in a StudentRepository class:

public class StudentRepository : BaseRepository<Student>, IStudentRepository
{
   public StudentRepository(AppDbContext context) : base(context) // Injected DbManager -> AppDbContext to StudentRepository
   {
   }
}

-----------------------------------------------------------------------------

public interface IStudentRepository : IRepository<Student>
 {
 }
 
  • In above code, BaseRepository is from "DbManager" library, and IStudentRepository must inherit from "IRepository" of "DbManager" library.

Utilize Pre-defined CRUD Operations

With DbManager integrated into your project, you can take advantage of all the CRUD methods already defined in the BaseRepository class. Here is a quick overview:

  • FindAsync : Find a single entity based on a provided predicate.
  • FetchListBySPAsync: Fetch a list of entities using a stored procedure and parameters.
  • GetAllAsync: Get all entity objects.
  • GetByIdAsync: Retrieve an entity object based on its ID.
  • InsertAsync: Insert a new entity object into the database.
  • UpdateAsync: Update an existing entity object.
  • DeleteAsync : Delete a single entity object.

Remember, all methods are asynchronous, so ensure you use async/await properly while calling them.

Congratulations! You've successfully configured DbManager for your project!

For more detailed information and usage examples, refer to our documentation.

Note: Make sure to add a project reference to DbManager in your solution to access the BaseRepository class and other utilities. For any queries or issues, please reach out to our support team.

Happy Coding with DbManager!

Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.0.0 131 1/14/2024
1.0.5 78 4/14/2024
1.0.4 180 11/25/2023
1.0.3 113 10/30/2023
1.0.2 106 10/29/2023

- Pagination added to FindAsync, GetAllAsync method