Upload
alin-alifah
View
289
Download
2
Embed Size (px)
Citation preview
Alin Nur Alifah
Alinalinnural.com
@alinnural
GNU Linux Bogor Activist
WEB Developer @IPB
Ilkomerz @IPB
Thank you
Thank youFor join my class
Lets sharing...
.NET ???
.NET ???.NET is a layer of software that makes it easier for you to write
programs
.NET Core Vs
.NET Framework
.NET Core Vs
.NET Framework
.NET Core is a general purpose, modular, cross-platform and open source implementation of the .NET Platform.
.NET with C# Languange
C# LanguangeThe C# language is disarmingly simple, which makes it good for beginners, but
C# also includes all the support for the structured, component-based, object-oriented programming that one expects of a modern language built on
the shoulders of C++ and Java.
Lets Code...
Install dotnet
# sudo zypper install libunwind libicu
# curl -sSL -o dotnet.tar.gz https://go.microsoft.com/fwlink/?LinkID=827532
# sudo mkdir -p /opt/dotnet && sudo tar zxf dotnet.tar.gz -C /opt/dotnet
# sudo ln -s /opt/dotnet/dotnet /usr/local/bin
Let's initialize a sample Hello World application!
# mkdir hwapp
# cd hwapp
# dotnet new
# dotnet restore
# dotnet run
Let's initialize a sample Hello World application!
Simple ASP.NET Core Application
Node.js and npm is required !
Install node.js and npm
# wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.31.7/install.sh | bash
# source ~/.bashrc
# nvm install v.x.xx.x
Scaffolding usings Yeoman
Install the necessary yeoman generators and bower using npm.
# npm install -g yo generator-aspnet bower
Run the ASP.NET Core generator
# yo aspnet
# dotnet restore# dotnet run
Scaffolding usings Yeoman
Scaffolding usings Yeoman
Sub Generators
https://github.com/omnisharp/generator-aspnet#sub-generators
eg : add a new class # yo aspnet:mvccontroller BlogController
Connect DatabaseNew SQLite Database
"dependencies": { "Microsoft.EntityFrameworkCore.Sqlite": "1.0.0", "Microsoft.EntityFrameworkCore.Design": { "version": "1.0.0-preview2-final", "type": "build" }
"tools": { "Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final" }
Connect Database
Verify that Entity Framework is installed by running
# dotnet ef - -help
Run dotnet restore again to install the new packages.
# dotnet restore
Create Model
Generate Database
This will find our context and models, and generate a migration
# dotnet ef migrations add MyFirstMigration
create the database file and creates the tables
# dotnet ef database update
Use Model on Controller
[HttpGet] [AllowAnonymous] public IActionResult Index(string nama = null) { var db = new BloggingContext(); db.Blogs.Add(new Blog { Url = nama }); db.SaveChanges();
ViewData["daftarBlog"] = db.Blogs; return View(); }
Thank you
Referensihttps://docs.asp.net/en/latest/tutorials/your-first-mac-aspnet.html
https://docs.asp.net/en/latest/client-side/yeoman.htmlhttps://github.com/omnisharp/generator-aspnet#sub-generators