Com.Atomatus.BootStarter
0.0.56
dotnet add package Com.Atomatus.BootStarter --version 0.0.56
NuGet\Install-Package Com.Atomatus.BootStarter -Version 0.0.56
<PackageReference Include="Com.Atomatus.BootStarter" Version="0.0.56" />
<PackageVersion Include="Com.Atomatus.BootStarter" Version="0.0.56" />
<PackageReference Include="Com.Atomatus.BootStarter" />
paket add Com.Atomatus.BootStarter --version 0.0.56
#r "nuget: Com.Atomatus.BootStarter, 0.0.56"
#addin nuget:?package=Com.Atomatus.BootStarter&version=0.0.56
#tool nuget:?package=Com.Atomatus.BootStarter&version=0.0.56
Atomatus BootStarter
What is BootStarter?
BootStarter is a cross-platform library designed to simplify and accelerate the startup of Entity Framework Core projects. It follows a domain-driven design approach and leverages middleware pipelines and dependency injection strategies.
The BootStarter project provides a set of abstract and contract classes to help modularize domain entities and services, including:
It also includes service contracts like:
BootStarter implements a repository pipeline pattern to persist data using Entity Framework and DbContext, with support for Unit of Work through:
How to Install?
Installing the Com.Atomatus.BootStarter
Package via NuGet
To begin, you'll need NuGet installed in your project. NuGet is a package manager for .NET projects that makes it easy to add and update third-party libraries and packages.
Here are the steps to install the Com.Atomatus.BootStarter
package:
Open Visual Studio or Your Preferred IDE:
Make sure your .NET project is open in your IDE.
Access the NuGet Package Manager Window:
- In Visual Studio, go to
Tools > NuGet Package Manager > Manage NuGet Packages for Solution
.
- In Visual Studio, go to
Search for the Package:
In the NuGet Package Manager, on the "Browse" tab, type
Com.Atomatus.BootStarter
into the search bar.Select the Package:
When the
Com.Atomatus.BootStarter
package appears in the search results, click on it to select it.Install the Package:
Click the "Install" button to initiate the package installation. NuGet will automatically download and install the package along with its dependencies into your project.
Verify the Installation:
After the installation is complete, you will see the package listed in your solution, and relevant files will be added to your project.
Import the Package in Your Code:
To start using the
Com.Atomatus.BootStarter
package, you can import the relevant namespaces in your code files as needed.using Com.Atomatus.BootStarter;
Bootstarter database types available
How to Use?
First: choose your strategy design, for example, DDD;
Short abstract about DDD layers
Presentation
- Layer responsible for covering everything that concerns the UI (user interface).
- Desktop UI (WinForms, WPF);
- Web UI (Angular, React, Vue);
- Mobile UI (Android, Xamarin).
- Layer responsible for covering everything that concerns the UI (user interface).
-
- All ways of remote communication must take place here.
- Web API (REST);
- SignalR;
- WebSockets.
- All ways of remote communication must take place here.
-
- Layer responsible for direct communication with the Domain layer. Implementing here:
- Application services Classes;
- Contracts (Interfaces);
- Data Transfer Objects (DTO);
- Auto Mapper.
- Layer responsible for direct communication with the Domain layer. Implementing here:
-
- This layer contains the domain entities, stand-alone domain services, respositories contracts (interfaces), domain entity validation and bussines rules. So, DDD happens here.
- Entities;
- Service Contracts;
- Respository Contracts;
- Stand-Alone domain services;
- Validations;
- This layer contains the domain entities, stand-alone domain services, respositories contracts (interfaces), domain entity validation and bussines rules. So, DDD happens here.
-
- Layer that supports the other layers. Which is currently divided into two layers (Infra and CrossCutting) with their respective contents.
Infra:
- Sublayer of infrascture, responsible to persist data.
- Repositories;
- Data Model;
- Data Persistence;
- Sublayer of infrascture, responsible to persist data.
CrossCutting:
- Sublayer of infrascture, responsible to cross all other layers applying Ioc (Inversion of control), dependency-injection.
- Ioc;
- Dependency Injection;
- Register all Dependency reference and implementation, see more about it here;
- Sublayer of infrascture, responsible to cross all other layers applying Ioc (Inversion of control), dependency-injection.
- Layer that supports the other layers. Which is currently divided into two layers (Infra and CrossCutting) with their respective contents.
Second: choorse your architecture, for example, Clean Architecture. In Clean Architecture, software systems are organized into distinct layers or concentric circles, each with a specific purpose. Here's an explanation of the layers in
Clean Architecture
:Domain Layer: The Domain Layer represents the core of the application and contains the business logic, rules, and entities. It defines the fundamental building blocks of the application and is independent of any external concerns, such as the user interface or database. In this layer, you define your domain models, entities, value objects, and business logic. It should be free from any framework-specific code.
Infrastructure Layer: The Infrastructure Layer is responsible for handling external concerns and technical details. It includes components like databases, file systems, external services, and frameworks. This layer is where you interact with data storage, handle cross-cutting concerns like logging and configuration, and implement infrastructure-specific code. It should not contain any business logic and should be replaceable without affecting the core domain.
Application Layer: The Application Layer contains the application-specific logic that coordinates the interaction between the Domain Layer and the Infrastructure Layer. It includes use cases, services, and application-specific rules. Use cases represent specific application actions or scenarios, often corresponding to user stories or system functionality. Services can encapsulate business logic that doesn't naturally fit into entities or value objects. The Application Layer acts as a bridge between the domain and infrastructure, ensuring that business rules are applied and data is retrieved or stored appropriately.
Presentation Layer: The Presentation Layer is responsible for interacting with the user or external systems. It includes components like user interfaces (UI), web APIs, and controllers. This layer translates user inputs or external requests into actions that the Application Layer can understand and execute. It also presents information from the Application Layer to the user or external systems in a format they can consume. The Presentation Layer is typically the most replaceable part of the system, as long as it adheres to the contracts established by the Application Layer.
In Clean Architecture
, the key principle is the separation of concerns, ensuring that each layer has a specific and well-defined responsibility. This separation allows for easier maintenance, testability, and adaptability of the software system. Changes in one layer should not require modifications in other layers, promoting flexibility and long-term sustainability. Additionally, the architecture enforces a clear boundary between business logic and technical details, making it easier to reason about and evolve the software over time.
Layer Types In Use
Domain
Then, in your Domain layer contains the domain entities, stand-alone domain services.
Remember that any domain concepts that depends on external resouces, are defined by interfaces and this interfaces implementations have to be in Infrascture Layer.
Now, following up the above concept were created the entity example class Client.
Domain class from IModel<ID> (and optionally of IModelAltenateKey) Full Implementatin.
public partial class Client : IModel<long>, IModelAlternateKey { public long Id { get; set; } public Guid Uuid { get; set; } public int Age { get; set; } public string Name { get; set; } }
Domain class from ModelBase
This class contains the properties Id and Uuid defined it.
public partial class Client : ModelBase<long> { public int Age { get; set; } public string Name { get; set; } }
Domain class from AuditableModel
This class contains the properties Id and Uuid defined it, and when created or updated register the date time for it in entity.
public partial class Client : AuditableModel<long> { public int Age { get; set; } public string Name { get; set; } }
Domain class Validation
Sometimes you must implement somes validations, for it, override Validate method from IModel<> implementation.
public partial class Client { protected override IEnumerable<ValidationResult> Validate(ValidationContext validationContext) { if (Age < 1 || Age > 200) { yield return new ValidationResult("Invalid Age value", new[] { nameof(Age) }); } else if (string.isNullOrWhiseSpace(Name)) { yield return new ValidationResult("Invalid Name!", new[] { nameof(Name) }); } } }
Domain class as Repository Entity
When use the domain class as Repository Entity, you can explicit create a non public Configure method to define entity creationg rules.
Then your ContextBase object (DBContext) when creating or migrating database in OnModelCreating(ModelBuilder) will looking for explicit definition of IEntityTypeConfiguration for current Entities defined in DbSet<> properties or by explicit definition, like below.
public partial class Client { protected void Configure(EntityTypeBuilder<Client> builder) { builder .Property(e => e.Age) .HasMaxLength(3) .IsRequired(); builder .Property(e => e.Name) .HasMaxLength(100) .IsRequired(); } }
Warning: Define only your own Properties, the Id and UUid (when present) are defined automatically
Infrastructure
In Infrastructure project layer, you can define explicitly the ContextBase as an UnitOfWork, the entities repositroy configuration map.
How like, displaying bellow.
Entity Configuration mapping
public class ClientMapping : EntityTypeConfigurationBase<Client, long>
{
protected override void OnConfigure(EntityTypeBuilder<Client> builder)
{
builder
.Property(e => e.Age)
.HasMaxLength(3)
.IsRequired();
builder
.Property(e => e.Name)
.HasMaxLength(100)
.IsRequired();
}
}
Mapping entity explicitly, if using ContextBase class all entities mapping will be found automatically as along as existing at same assembly entity definition. Otherwise, must setup this configurations mapping on ContextBase.OnModelCreating(ModelBuilder)<br/>
[Db]ContextBase as UnitOfWork
Take on that the client mapping below is not present in the same assembly of entity client definition, We must set it manually.
public class LocalContext : ContextBase
{
public DbSet<Client> Clients { get; internal set; }
public LocalContext(DbContextOptions options) : base(options) { }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
// Here, the base class will attempt to load entity mappings
// from the same assembly as each DbSet property in LocalContext.
base.OnModelCreating(modelBuilder);
// However, please note that the client mapping below is not
// included in the same assembly as the Client entity definition.
// Therefore, we need to set it manually.
modelBuilder.ApplyConfiguration(new ClientMapping());
}
}
Registering the context setup direct to database type.
The IServiceCollection
can setup the dbContext using the method AddDbContext, to use as Bootstarter the method name start are equals, but with sufix AddDbContext[[AsDatabaseType]]
.
public class Startup
{
//...
public void ConfigureServices(IServiceCollection services) {
services.AddDbContextAsSqlServer<LocalContext>();
}
}
Or can you register the context base as dynamic and using Ioc concept to register the entities services CRUD, how like, displaying bellow.
public class Startup
{
//...
public void ConfigureServices(IServiceCollection services) {
//Add DbContext for SQL Server database type
//for dynamic context, must setyp entities.
//But, you can setup connection configurations, services and context lifetime.
services.AddDbContextAsSqlServer(s => s.AddServiceTo<Client>());
}
}
Services
Generate services in application layer to consume infrastructure and provides an access to it. Services can encapsulate business logic that doesn't naturally fit into entities or value objects. The Application Layer acts as a bridge between the domain and infrastructure, ensuring that business rules are applied and data is retrieved or stored appropriately.
public interface IClientService : IServiceCrud<Client, long> { }
internal class ClientService :
ServiceCrud<LocalContext, Client, long>,
IClientService
{
//using constructor to discovery
//client dbset
public ClientService([NotNull] LocalContext context)
: base(context) {}
//or
//using constructor explitily setup
//cient dbset
public ClientService([NotNull] LocalContext context)
: base(context, context.Clients) {}
}
Infrastructure CrossCuting
Generate and add services to Entities. You can setup it explity or from implicit way in dynamic context.
public void ConfigureServices(IServiceCollection services)
{
services.AddDbContextAsSqlServer<LocalContext>()
//using dynamic service CRUD generation for your context and model.
//This service is accessible by
//IServiceProvider method GetServiceTo<Client>() or
//passing the GetService<IServiceCrud<Client>>.
.AddService<LocalContext, Client, long>()
//or explicitly setup your service implementation.
.AddScoped<IClientService, ClientService>();
//dynamic DBContext way
//Creating service to entity client
//to generate accessible service to IServiceCrud.
services.AddDbContextAsSqlServer(
s => s.AddServiceTo<Client>()
);
}
See more database types in Bootstarter database types available readme.md files.
License
BootStarter (including the runtime repository) is licensed under the Apache license.
© Atomatus - All Rights Reserveds.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net6.0
- Microsoft.EntityFrameworkCore (>= 7.0.14)
- Microsoft.EntityFrameworkCore.Relational (>= 7.0.14)
- Microsoft.Extensions.Configuration (>= 7.0.0)
- Microsoft.Extensions.Configuration.FileExtensions (>= 7.0.0)
- Microsoft.Extensions.Configuration.Json (>= 7.0.0)
- Microsoft.Extensions.DependencyInjection (>= 7.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 7.0.0)
- System.Reflection (>= 4.3.0)
- System.Reflection.Emit (>= 4.7.0)
- System.Reflection.Primitives (>= 4.3.0)
NuGet packages (6)
Showing the top 5 NuGet packages that depend on Com.Atomatus.BootStarter:
Package | Downloads |
---|---|
Com.Atomatus.BootStarter.Web
A versatile framework for building robust and efficient RESTful web APIs in C# using ASP.NET Core. It provides a set of powerful tools and abstractions that simplify common development tasks, allowing developers to focus on building and maintaining their API endpoints. |
|
Com.Atomatus.BootStarter.Sqlserver
Bootstarter library for sqlserver repository |
|
Com.Atomatus.BootStarter.Postgres
Bootstarter library for postgresSQL repository |
|
Com.Atomatus.BootStarter.Sqlite
Bootstarter library for sqlite repository |
|
Com.Atomatus.BootStarter.Cosmos
Bootstarter library for noSql CosmoDB repository |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated |
---|---|---|
0.0.56 | 142 | 6/4/2025 |
0.0.55 | 133 | 6/4/2025 |
0.0.54 | 132 | 6/4/2025 |
0.0.53 | 1,418 | 11/23/2023 |
0.0.52 | 262 | 11/23/2023 |
0.0.51 | 232 | 11/23/2023 |
0.0.50 | 241 | 11/22/2023 |
0.0.49 | 444 | 11/21/2023 |
0.0.48 | 196 | 9/13/2023 |
0.0.47 | 187 | 9/11/2023 |
0.0.46 | 185 | 9/10/2023 |
0.0.45 | 203 | 9/10/2023 |
0.0.44 | 207 | 9/3/2023 |
0.0.43 | 411 | 9/2/2023 |
0.0.42 | 721 | 8/30/2023 |
0.0.41 | 199 | 8/28/2023 |
0.0.40 | 202 | 8/27/2023 |
0.0.39 | 215 | 8/26/2023 |
0.0.38 | 237 | 8/26/2023 |
0.0.37 | 257 | 8/26/2023 |
0.0.36 | 153 | 8/25/2023 |
0.0.35 | 188 | 8/25/2023 |
0.0.34 | 196 | 8/25/2023 |
0.0.33 | 154 | 8/25/2023 |
0.0.32 | 170 | 8/23/2023 |
0.0.31 | 183 | 8/23/2023 |
0.0.30 | 208 | 8/15/2023 |
0.0.29 | 215 | 8/14/2023 |
0.0.28 | 170 | 8/14/2023 |
0.0.27 | 190 | 8/14/2023 |
0.0.26 | 179 | 8/14/2023 |
0.0.25 | 217 | 8/14/2023 |
0.0.24 | 191 | 8/13/2023 |
0.0.23 | 215 | 8/13/2023 |
0.0.22 | 211 | 8/13/2023 |
0.0.21 | 198 | 8/12/2023 |
0.0.20 | 607 | 8/12/2023 |
0.0.19 | 221 | 8/11/2023 |
0.0.18 | 1,339 | 4/7/2023 |
0.0.17 | 1,143 | 4/30/2021 |
0.0.16 | 1,131 | 4/29/2021 |
0.0.15 | 2,298 | 4/29/2021 |
0.0.14 | 1,033 | 4/28/2021 |
0.0.13 | 1,494 | 4/24/2021 |
0.0.12 | 1,211 | 4/23/2021 |
0.0.11 | 1,491 | 4/22/2021 |
0.0.10 | 1,524 | 4/20/2021 |
0.0.9 | 1,215 | 4/18/2021 |
0.0.8 | 2,070 | 4/17/2021 |
0.0.7 | 384 | 4/17/2021 |
0.0.6 | 1,081 | 4/17/2021 |
0.0.5 | 1,081 | 4/16/2021 |
0.0.4 | 822 | 4/13/2021 |
0.0.3 | 1,799 | 4/12/2021 |
0.0.2 | 1,216 | 4/11/2021 |
0.0.1 | 404 | 4/11/2021 |