Install and Setup FlashServer
The FlashServer is a wrapper for EntityFrame Core you can use to create a New Project.
Or, migrate an existing Project to FlashServer.
Perquisites
- .Net SDK -
.NET 6.0 SDKor higher - Text Editor - I recommend Visual Studio 2022 or VS Code with C# Dev Kit
- Terminal - FlashServer is easier to setup and navigate with FlashServer CLI
Installing the CLI
For the CLI you can…
dotnet tool install --global FlashServer.CLIQuick Start
Create a new API Project
- From the File menu, select New > Project.
- Enter Web API in the search box.
- Select the ASP.NET Core Web API template and select Next.
- In the Configure your new project dialog, name the project APINAME and select Next.
- In the Additional information dialog:
- Confirm the Framework is .NET 6.0+ (Long Term Support).
- Confirm the checkbox for Use controllers(uncheck to use minimal APIs) is checked.
- Select Create.
Add Nuget Package
- From the Tools menu, select NuGet Package Manager > Manage NuGet Packages for Solution.
- Select the Browse tab.
- Enter FlashServer in the search box, and then select
FlashServer - Select the Project checkbox in the right pane and then select Install.
dotnet new webapi --use-controllers -o <APINAME>cd <APINAME>dotnet add package FlashServercode -r ../<APINAME>Now your project should look like this
DirectoryProperties
- launchSettings.json
DirectoryControllers
- WeatherForecastController.cs
- appsettings.json
- appsettings.Development.json
- Program.cs
- WeatherForecast.cs
- APINAME.csproj
Setup the API
Now that you created a new project or installed the library its time to setup your API.
-
Add to your appsettings.json a connection string to your SQL server:
appsettings.js {"ConnectionStrings": {"DefaultConnection": "Server=YOURSERVERNAME; Database=YOURDATABASENAME; Trusted_Connection=True; MultipleActiveResultSets=true"}} -
Create a context file for your project
context.cs public class YOURCONTEXT : BaseContext<YOURCONTEXT>{public YOURCONTEXT(DbContextOptions<YOURCONTEXT> options) : base(options){}} -
Add the SQL server to your Program.cs and configure the services for the mangers and automapper profiles
Program.cs builder.Services.AddDbcontextFactory<YOURCONTEXT>(options => options.UseSqlServer(builder.Configuration.GetConnectionString("DefaultConnection")));Assembly assembly = Assembly.GetExecutingAssembly();builder.Services.AddAutoMapper(assembly);builder.Services.AddManipulationManagers(assembly); -
Add your models to your project
-
Add your manipulation managers and controllers to your project either by using the CLI or manually creating them
Terminal window flashServer Init --folder <Models Folder>This will modify the project directory with all the necessary files for your API project.
-
Run your project
Terminal window dotnet run -
Open your browser and navigate to
https://localhost:5001/swagger/index.html