Code Generation For C#, WPF, WCF, SQL SERVER/ORACLE/MYSQL and Visual Studio 2013-2017

Tutorial - Database to ASP.NET Core 2 (+ Identity) Mvc in 5 minutes
So you have a database and you want to front it with an Asp.Net Core (2+) MVC based application. You might also want to use the Identity framework to manage users and roles. But what you dont want to do is build in a dependency on EntityFramework or other ORM. This article shows you how to accomplish all that in 5 minutes. So follow along and embrace the freedom of .NetCore Mvc with no EntityFramework/Third Orm, just 100% code. This exercise requires Visual Studio 2017, with CodeTrigger 6.1+ installed. You will need a database, This article uses Microsoft SQL Server, and the Northwind sample database.

CodeTrigger solution and Wizard selection

Open up Visual Studio, click on the Tools extension and open up the CodeTrigger tab. Click on the 'New CodeTrigger Project' icon in the CodeTrigger menu bar. Enter the following values:
Solution Name: CodeTriggerSampleSln
Location: c:\codetriggersamples\db-to-core-mvc
Wizard: 'DB to Multi-tier .Net Core2 (VS2017 only)'
Click Next

Project name and wizard options

On the next wizard page Enter:
Project Name: WebApp1
Options List select 'Use Asp.Net Identity' and leave other options unselected
(If you have used the same database for previous versions of CodeTrigger MVC with Identity, you will need to delete the old identity tables in the database as the identity schema in .Net Core 2 has changed and CodeTrigger will not regenerate the new schema tables if it detects the old ones).
Click Next

Data Source Details

On the next wizard page Enter:
Data Source Enter the datasource details eg database server name and database name. If using SQL server and the northwind or other small sample database you can leave the 'Schema' text box blank. Click 'Connect' to verify your settings. If connection is successful, click 'Create'. The Project is created and loaded into Visual Studio.

Select initial schema objects

Schema objects & business objects In the 'Schema Objects' tab select (tick checkbox next to) a couple of tables detected from your database, (eg from northwind I select 'dbo.Customers' and 'dbo.Employees') and click the 'Business Objects' tab.

CodeTrigger builds an internal relationship model around the tables/views you have selected, based on the schema information available in the database, and may display a handful of more tables in the Business Objects tab that you originally selected, if it detected any relationships between them.

In the Business Objects tab, tick the check box next to the objects representing your original couple of tables selected (eg 'BOCustomers' and 'BOEmployees')
Hit the red 'Generate Code' button.

Project and references Within seconds all the code required to support your selections is generated into the Visual Studio project. Explore the visual studio solution to see that there is no dependency on EntityFramework, or other ORM, just 100% code. The project does references Microsoft.AspNetCore.All nuget package, (which in turn contains EF references). Referencing the AspNetCore.All package is just a way to simplify your project file instead of individually listing all the components. However EF components are not referenced in the code and there is a Trim task to remove unwanted assemblies on build and deploy, so all those assemblies are ultimately removed from the deploy folder.

Hit F5 (or similar) to build and run.

Your new web app opens up showing the home page. Click on 'Log in' and type in the example login details shown on the login screen.
Click into the 'Customers' link to see the customers page, and play with it.
Click on the 'Admin' link to manage users, and roles, using the .net Identity framework.

Thats all it takes, database to aspnetcore 2 (+Identity) mvc application in 5 mins, using CodeTrigger 6.1+