Overview and updates
ApiNCoreEx is a solution template VS 2017/2019 extension for building .NET Core API EF solutions.
Generate 100s lines of code on a single click and save hours of searching Web and testing for the right solution.
A great start for REST API service based on latest .Net Core.
- Three layers: Api, Domain and Entity
- DI (.NET Core feature)
- Generic Service and Repository with Entity Framework ORM
- Sync and Async calls
- Generic exception handler
- Serilog logging with Console and File sinks
- EF migration and seed from json objects
- JWT authorization and authentication option
- Implemented IdentityServer4 with an OpenID Connect and OAuth 2.0 framework for ASP.NET Core.
- Swagger and Swashbuckle with ASP.NET Core
- API versioning
Full version extra features:
- XUnit integration tests (http client) run for both authentication types: JWT or IS4 (only change appsettings).
- Postman API tests (JWT and IS4) for import as json file
- T4 templates for code generation/scaffolding for Domain, Service, Controller and UnitTests when added new entity classes (inherits from BaseEntity).
- EF stored procedure example
Updates (.NET Core 2.2 version):
- Version 3.0 (.NET Core 2.2)
- Version 3.1 (added Swagger authentication)
- Version 3.2 (fix POST/PUT use; update unittests)
- Version 3.3 (time saving T4 template code generation for domain. service, controller and tests classes)
- Version 3.4 (fix T4 template for code generation of tests classes)
- Version 3.5 (db lazy loading)
- Version 3.6 (Update unittests, add load test,add test appsettings for remote database and update Repository Update method)
- Version 3.7 (DB concurrency for update, unittests refactored and updated)
- Version 3.8 (Add predicate search examples service call)
- Version 3.9 (Update/fix T4 template code)
- Version 4.0 (API versioning)
- Version 4.1 (Added CodeGeneratorUtility.bat to execute all T4s and updated Domain classes T4 script)
- Version 4.2 (EF fix add-migration and updated T4 templates for DI services)
Updates (.NET Core 3.x version):
- Version 4.1 (.NET Core 3.0 - Initial)
- Version 4.2 (API versioning)
- Version 4.3 (Added CodeGeneratorUtility.bat to execute all T4s and updated Domain classes T4 script)
- Version 4.4 (Update to .NET Core 3.1 - LTS version )
- Version 4.5 (Automapper v.9.0 with DI)
- Version 4.6 (updated T4 templates for DI services and tests code generation)
- Version 4.7 (updated to Swashbuckle.AspNetCore Version=5.0.0)
- Version 4.8 (added an example of using stored procedures)
- Version 4.9 (fixed the issue with using a dot in a solution name)
and install full featured extension (VSIX) (or free version
2. Open Visual Studio and select new ApiNCoreE(x) (with ER ORM) solution template from Visual C# templates section.
3. Nuget dependencies should be restored automatically with Internet connection. If that is not happening then you can use command 'Manage Nuget Packages -> Restore' and run for each project.
4. Set and save in connection string only "Data Source" (server name) in configuration file (appsettings.json) for API project and Test project(only full version):
"ConnectionStrings":"YourSolutionNameDB": "Data Source=CopyHereYourServerName;Initial Catalog=YourSolutionName;...",
5. Make sure that startup project is API and run Visual Studio solution which automatically initiates migration/seed services to get the API service info page. Note that by default JWT is used as authentication service for the API.
6. Test with Swagger API specification link using credentials email@example.com
to get security token.
The solution run triggers the database migration and data seed code which creates and populates initial tables.
In order to use IndentityServer4 as authentication service for the API, you can update configuration file (appsettings.json) in API project with this setting:
Extended VSIX version steps:
7. Set and save in configuration file (appsettings.json) in Test project connection string "Data Source" and authentication type JWT like:
7. Run all integration tests in Test project. It is used JWT as authetication service for the API.
8. Set and save in configuration file (appsettings.json) in Test project this setting:
8. Build the solution.
9. Run all tests in Test project. It is used Indentity Server 4 as authetication service for the API.
10. Import Postman_tests_collection.json from Test project folder to Postman
11. Run JWT tests in Postman runner.
12. Set and save in configuration file (appsettings.json) in API project this setting:
13. Build the solution.
14. Run IS4 tests in Postman runner.
T4 templates code generation/scaffolding:
Create new entity class (must inherit from BaseEntity) in Entity project, Entity folder,
To execute all T4 templates right-click on CodeGeneratorUtility.bat (Entity project) file and OpenWith command using PowerShell (may need to -Add...- PowerShell program) .
In order to execute manually use T4 template right-click on specific tt file and Run Custom Tool command.
If executing manually find end execute T4 templates in THIS order:
Use PM console (set Entity project as default one) to add new migration and update database (see commands in Entity project _nugets.txt for PM console)
Run all unit tests.
With these scaffolding routines, hundreds lines of code could be generated.
- Entity project 1_t4EntityHelpersGenerate.tt
- Domain project Domain folder 2_t4DomainViewModelsGenerate.tt
- Domain project Mapping folder 3_t4DomainMappingProfileGenerate.tt
- Domain project Service folder 4_t4DomainServicesGenerate.tt
- API project Controller folder 5_t4ApiControllerGenerate.tt
- API project Setup additions 5_t4ApiStartupAdditionsGenerate.tt
- Test project 6_t4IntegrationTestGenerate.tt
Swagger API tests:
Set and save in configuration file (appsettings.json) in API project this setting to use JWT authentication:
Run API service and click Swagger API specification button.
Find Token service (JWT), use Try it out button and enter these values (exists in test project code and match values in User table)):
Execute Token service and copy returned token value: eyJhbGc...
Click Authorize button on the top of the Swagger page and add value
Bearer eyJhbGc.... Click Authorize button.
All service calls are now authorized and can be tested.
Download full version of VSIX
Download full-featured VSIX extensions for VS2017 and VS2019
(with time-saving T4 code generation; with XUnit project integration tests and Postman tests)
Get two ApiNCoreEx.vsix (.NET Core 3.1 and .NET Core 2.2) extensions with Entity Framework, Indentity Server 4 or JWT, T4 code generation for domain, controller, test and DI, XUnit project integration tests, Swagger API and Postman tests json file.
Get 2 extensions for $24 CAD and save many hours to start with fully functional .NET Core REST API with all layers code scaffolding driven by added entity classes.
Get 5 extensions for $33 CAD and save many hours to start with fully functional .NET Core REST API.
Please use Paypal "Return to merchant" link after your payment in order to get VSIXs download page.
You have 30 days to download the product using received link.
If you have problems to download purchased VSIXs please contact us at firstname.lastname@example.org and we will send you the download link.
Note that no support is available for generated code with these VSIX extensions; however please let us know about suggestions, issues or improvements regarding solutions generated by the VS extensions.
Extensions' icons thanks to cjdowner.
Note that there is no restriction to use, copy, modify, and distribute software created with this Visual Studio extension template. The extension resell is forbidden! Created solution using this template may contain code with unintentional flaws or limitations. Please adjust created solution to your needs and test it before any production use. IN NO EVENT SHALL OWNER OF THIS EXTENSION BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE OWNER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.