8000 GitHub - axlln/es-quick-start: Quick start for // entity services
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

axlln/es-quick-start

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 

Repository files navigation

What is //entity services

//entity services is a tool that will help you speed up the development of enterprise .NET solutions.

Using //entity services, in just few minutes you can create fully functional C# source code based on a simple configuration.

We don't use ChatGPT or one of the LLMs to generate the code based on the configuration, //entity services uses smart templates and architecture carefully designed and tested by our experts to produce code that is consistent, reproducable, secure, customisible and extendable.

We use AI ONLY as just as another way for defining and generating the configuration files using natural language, not for the code generation.

Generated .NET solution includes:

  • Data layer projects that follow repository pattern with read and write pipelines composed of components for validation, caching, security and with various storage options (SQL Server, MongoDB,..),

  • Data-centric entities models,

  • Web API project that exposes endpoints with standard CRUD methods with versioning, API documentation and .http files for testing

The solution follows industry best practices, it is designed to be easily customizable and deployed to any cloud or on premisses.

Read more about //entity services , watch short introduction video, browse the documentation or follow the quick start instructions to try it out!

entity services

Licensing

Generated source code is yours. You can change it as you want and use it in the commercial projects.

Contributing

We would like to get your feedback!

We are using discussions page as a place to connect with other members of our community. Ask questions you are wondering about, share ideas, engage with other community members. Remember that this is a community we build together 💪.

Quickstart

Here is the development process with //entity services:

  1. Install .NET tool es-builder
  2. Describe models and define solution components
  3. Start es-builder to generate the source code
  4. If necessary, customize generated source code
  5. Build and run your solution
  6. Use generated OpenAPI client and .http scripts to easily test your application

1. Install .NET tool es-builder

Make sure that you have .NET 6 installed on your system.

Add Entity Services NuGet Source:

dotnet nuget add source https://pkgs.dev.azure.com/entityservices/nugets-lite/_packaging/es-lite/nuget/v3/index.json --name entityservices 

Install Entity Services Builder Cli:

dotnet tool install es-builder-cli -g

where flag -g will install it globally.

2. Define models and solution components

es-builder tool will create source code based on YAML files that define:

  • definition of entities,
  • selected components for repository (Entity Framework, Azure Cosmos Db, etc.) and
  • configuration of project naming and files structure.

You can choose one of the configuration examples from this repo, such as examples/entity-framework-quickstart.yml if you want to use Sql Server, or examples/mongodb-quickstart.yml for NoSql database and copy it in your local folder.

If you want to create your own data model definitions, continue reading about the Entity Services Portal, otherwise skip to the next step.

Entity Services Portal

The easiest way to define entities is using //entity services portal. The portal provides forms to manage entities and their properties. The AI enhanced prompt helps creating multiple entities models in few seconds.

portal

The portal comes pre-populated with a simple example of entities for a bookstore solution, but you can easily create the entities that fit your needs.

Examples of prompts:

  • Clear all (clears the current content)
  • Create entities for Pub management solution
  • I am creating an app for NHS. Created entities should include Hospital, Patient and Doctor
  • Rename entity Doctor to Physician
  • Set max length of all string properties of entity Physician to 200

Copy the generated YAML that describes the entities and save it as local file(s) into your working folder or subfolder. Use the extension .yml.

You will also need to define the components of the solution. The easiest way is to choose one of the configuration examples from this repo, such as examples/entity-framework-quickstart.yml if you want to use Sql Server, or examples/mongodb-quickstart.yml for NoSql database. Make sure to replace the entities with the one you created.

In folder /examples of this repo, you will find other examples of configuration. Here is a snippet you can use:

solutionName: "Axellon.Simple"
dataApi:
    entityGroups:
      - group: default
        enableHistory: false
        useGroupFolder: true
        readComponents:
          - type: MongoDbComponent
        writeComponents:
          - type: ValidationComponent
          - type: MongoDbComponent
        endpoints:
          - type: WebApiEndpoint

3. Start source code builder

Before using es-builder CLI commands, you need to sign in.

Run the login command:

es-builder login

If the CLI can open your default browser, it will open Entity.Services page for login or sign-up.

After successful login, start the build process with command:

es-builder build

When build command is started, it will use .yml configuration file(s) to create source code and store solution files in defined location. The default location it the folder where you started es-builder.

build-process

In aproximatelly 60 seconds you will have complete source code of the solution downloaded in your folder.

Here are the main components of the generated solution:

entity services

4. Customize generated source code

Use your favorite development IDE and customize generated source code per your requirements.

5. Build and run your solution

Make sure to set Web API project as your startup project. For example, if you are using Visual Studio, right-click on *.WebApi project and select option "Set as Startup Project".

To be able to test the solution you will need a data storage. Depending on which component you chose, you could use MongoDb or Sql Server.

MongoDb

To use MongoDb database you have to provide a connection string and create the collections for your entities in the database.

Connection string

The application will take the connection string from environment variable, appsettings file or user secrets file.

The connection string variable name should be ConnectionStrings__MongoDBConnectionString

The example of the connection string for Azure CosmosDb Mongo database

mongodb://my-demo-cosmos-account:<-secret->@my-demo-cosmos-account.mongo.cosmos.azure.com:10255/our-mongo?ssl=true&replicaSet=globaldb&retrywrites=false&maxIdleTimeMS=120000&appName=@my-demo-cosmos-account@

Replace <-secret-> with your secret and don't forget to restart the Visual Studio to pickup the new env variable.

Collections

The database has to contain a collection for each of your entities. For example, if you have defined "Asset" and "Commodity" entity in your configuration, the collections with the same names has to be created in the database.

CLI command

If you have a Azure subscription, you could use our CLI command to create a free database, collections and set up the connection string in the environment variable as described here.

Sql Server

To use Sql Server database you have to provide a connection string and create the tables for your entities in the database.

Connection string

The application will take the connection string from environment variable, appsettings file or user secrets file.

The connection string variable name should be ConnectionStrings__SqlConnectionString

Database Tables

To run the application that uses Sql Server as a storage, you will need to create the tables that match your entity definitions.

The easies way to create those tables in by using migration scripts and the Entity Framework migration tool, as described here.

Here is an example of the commands you have to run to create the migrations and update the database for one db context (you will need to run them for each Db context in your solution).

dotnet ef migrations add Initial_migration 
	--output-dir "C:\demo\Axellon.SimpleSql\src\Axellon.SimpleSql.Repository\Assets\Migrations" 
	--project "C:\demo\Axellon.SimpleSql\src\Axellon.SimpleSql.Repository\Axellon.SimpleSql.Repository.csproj" 
	--context AssetEntityContext 
	-- --cs "Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=Test;Integrated Security=True;Connect Timeout=30;Encrypt=False;Trust Server Certificate=False;Application Intent=ReadWrite;Multi Subnet Failover=False"



dotnet ef database update 
	--project C:\demo\Axellon.SimpleSql\src\Axellon.SimpleSql.Repository\Axellon.SimpleSql.Repository.csproj 
	--context AssetEntityContext 
	-- --cs "Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=Test;Integrated Security=True;Connect Timeout=30;Encrypt=False;Trust Server Certificate=False;Application Intent=ReadWrite;Multi Subnet Failover=False"

Now you can build and run your solution.

Enjoy coding things that matter and run your new solution!

6. Easily test your application with generated scripts

Http files

WebApi project contains folder HttpEndpoints with .http files. Their purpose is to allow executing HTTP commands via Visual Studio Code extension REST Client. Generated .http files can also be used in Visual Studio or Rider environments, with minimal adjustments.

Open API Web UI

Based on default settings in app.settings, upon start of WebApi project, web browser will be opened with OpenApi UI at the route /interactive-docs.

Need help?

About

Quick start for // entity services

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  
0