Skip to content

Sample project using .Net core 3.1 and MVC template. Academic sample

Notifications You must be signed in to change notification settings

dtarenas/NetCoreSample

Repository files navigation

NetCoreSample

Sample project using .Net core 3.1 and MVC template. Academic sample

We will using MVC and Web Api template to learn the base concepts about Net Core had been built. Moreover we will try to implement some razor views and html views searching compare the ways to create web applications.

Frontend

We'll use boopstrap 4 framework to build responsive views and vanilla Javascript to interact with DOM

To get base boopstrap template, please click Here.

Backend

We'll use dotnet core 3.1 to create different projects to match concepts between available projects on visual studio wizard.
Moreover, we'll need a any database engine and we'll EntityFrameworkCore to improve our approach.
So, For this sample I will use MySql (Click to Download)
Note: You can use wherever DB engine, feel like free!

Tools

  • Download Visual Studio 2019 Here.
  • Download Visual Studio Code Here.
  • Postman Here.

Remember: You must install all dependencies for net core. Like this

Scheduler Class

  1. Create a dot net core 3.1 project using visual studio 2019
  2. How To build a project on VS
  3. EntityFrameworCore (Code first approach)
  4. Create Context
  5. Build a MVC Prject and explain essencial functionality
  6. Add Javascript functionality
  7. Repository Pattern
  8. Refactor using Repos
  9. Build a Web API project
  10. To be continue...

Db Diagram

test2

Tips

  • Nuget dependencies:
    • Microsoft.EntityFrameworkCore
    • Microsoft.EntityFrameworkCore.Tools
    • MySql.Data.EntityFrameworkCore
    • Microsoft.EntityFrameworkCore.SqlServer
    • Microsoft.AspNetCore.Mvc.NewtonsoftJson
    • System.IdentityModel.Tokens.Jwt
    • Microsoft.AspNetCore.Authentication.JwtBearer
  • Connection String: "ConnectionStrings": { "DefaultConnection": "server=localhost;port=3306;user=root;password=Diego1.;database=net_core_sample"}
  • Add Context: services.AddDbContext(options => options.UseMySQL(this.Configuration.GetConnectionString("DefaultConnection")));
  • Resolve Json Responses: services.AddMvc() .AddNewtonsoftJson(options => options.SerializerSettings.ContractResolver = new DefaultContractResolver()) .AddNewtonsoftJson(options => options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore) .AddNewtonsoftJson(options => options.SerializerSettings.DateFormatHandling = DateFormatHandling.MicrosoftDateFormat) .AddNewtonsoftJson(options => options.SerializerSettings.DateTimeZoneHandling = DateTimeZoneHandling.Utc);
  • To Set JWT config services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) .AddJwtBearer(options => { options.RequireHttpsMetadata = false; options.SaveToken = true; options.TokenValidationParameters = new TokenValidationParameters() { ValidateIssuer = true, ValidateAudience = true, ValidAudience = Configuration.GetSection("JwtSettings").GetValue("Audience"), ValidIssuer = Configuration.GetSection("JwtSettings").GetValue("Issuer"), IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(Configuration.GetSection("JwtSettings").GetValue("Key"))) }; });
  • Nuget Manage Console:
    • Fist Time --> Add-Migration Initial
    • Update Database --> Update-Database (Update last Migration)
    • More times --> Add-Migration [PutHereChangeName]
    • Drop Database --> Drop-Database
    • Remove last Migration --> Remove-Migration

Many thanks,
Just do it! - Enjoy the play!

About

Sample project using .Net core 3.1 and MVC template. Academic sample

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published