Open 10tinsinh opened 2 years ago
services.AddDbContext(option => { option.UseSqlServer(Configuration.GetConnectionString("MyDB")); }); ------------Code First--------------- Add-Migration DbInit Update-database
------------DB First------------ Scaffold-DbContext "Data Source=DESKTOP-46U8TGP;Initial Catalog=RunningMan;Integrated Security=True" Microsoft.EntityFrameWorkCore.SqlServer -OutputDir Repository/Entites -context MyDbContext -contextdir Repository -DataAnnotations -Force
private readonly MyDbContext _context;
public HangHoaRepository(MyDbContext context) { _context = context; }
-------------------tutorial authorization--------------------- https://jasonwatmore.com/post/2019/10/16/aspnet-core-3-role-based-authorization-tutorial-with-example-api
var identity = HttpContext.User.Identity as ClaimIdentity; Ilist claim = identity.claims.Tolist(); var userName = claim[0].value;
services.AddDbContext(option =>
{
option.UseSqlServer(Configuration.GetConnectionString("MyDB"));
});
------------Code First---------------
Add-Migration DbInit
Update-database
------------DB First------------ Scaffold-DbContext "Data Source=DESKTOP-46U8TGP;Initial Catalog=RunningMan;Integrated Security=True" Microsoft.EntityFrameWorkCore.SqlServer -OutputDir Repository/Entites -context MyDbContext -contextdir Repository -DataAnnotations -Force
ASP.NET Core Web API | Entity Framework Core - Create CRUD APIs (Step by Step) [03]
private readonly MyDbContext _context;
-------------------tutorial authorization--------------------- https://jasonwatmore.com/post/2019/10/16/aspnet-core-3-role-based-authorization-tutorial-with-example-api
var identity = HttpContext.User.Identity as ClaimIdentity; Ilist claim = identity.claims.Tolist();
var userName = claim[0].value;