webapi core2.1 Identity.EntityFramework Core进行配置和操作数据 (一)没什么用
https://docs.microsoft.com/en-us/aspnet/core/security/authentication/identity?view=aspnetcore-2.1&tabs=visual-studio%2Caspnetcore2x 的实践
微软无api 的 identity 配置,专门写一篇关于 vs code 的配置
dotnet new webapi -o Demo
cd demo
dotnet add package Microsoft.AspNetCore.Identity.EntityFrameworkCore
Startup.cs
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Identity;
using Microsoft.EntityFrameworkCore;
using Demo.Data;
->ConfigureServices
services.Configure<CookiePolicyOptions>(options =>
{
// This lambda determines whether user consent for non-essential cookies is needed for a given request.
options.CheckConsentNeeded = context => true;
options.MinimumSameSitePolicy = SameSiteMode.None;
}); services.AddDbContext<ApplicationDbContext>(options =>
options.UseSqlServer(
Configuration.GetConnectionString("DefaultConnection")));
services.AddDefaultIdentity<IdentityUser>()
.AddEntityFrameworkStores<ApplicationDbContext>();
Data->ApplicationDbContext.cs 新建文件夹及文件
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore; namespace Demo.Data
{
public class ApplicationDbContext : IdentityDbContext
{
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
: base(options)
{
}
}
}
appsettings.json 加入数据库连接
"ConnectionStrings": {
"DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=aspnet-ids-3D54E4B2-38C1-466C-A12F-E9CCF493B11B;Trusted_Connection=True;MultipleActiveResultSets=true"
},
最后生成编译,
生成数据库映射表
更新数据库
dotnet build
dotnet ef migrations add Initial -o Data/Migrations
dotnet ef database update
webapi core2.1 Identity.EntityFramework Core进行配置和操作数据 (一)没什么用的更多相关文章
- webapi core2.1 IdentityServer4.EntityFramework Core进行配置和操作数据
https://identityserver4.readthedocs.io/en/release/quickstarts/8_entity_framework.html 此连接的实践 vscode ...
- mvc core2.1 Identity.EntityFramework Core 实例配置 (四)
https://docs.microsoft.com/zh-cn/aspnet/core/security/authentication/customize_identity_model?view=a ...
- 第15章 使用EntityFramework Core进行配置和操作数据 - Identity Server 4 中文文档(v1.0.0)
IdentityServer旨在实现可扩展性,其中一个可扩展点是用于IdentityServer所需数据的存储机制.本快速入门展示了如何配置IdentityServer以使用EntityFramewo ...
- mvc core2.1 Identity.EntityFramework Core 配置 (一)
https://docs.microsoft.com/zh-cn/aspnet/core/security/authentication/customize_identity_model?view=a ...
- mvc core2.1 Identity.EntityFramework Core ROle和用户绑定查看 (八)完成
添加角色属性查看 Views ->Shared->_Layout.cshtml <div class="navbar-collapse collapse"> ...
- mvc core2.1 Identity.EntityFramework Core 用户Claims查看(七)
添加角色属性查看 Views ->Shared->_Layout.cshtml <div class="navbar-collapse collapse"> ...
- mvc core2.1 Identity.EntityFramework Core 导航状态栏(六)
之前做的无法 登录退出,和状态,加入主页导航栏 Views ->Shared->_Layout.cshtml <div class="navbar-collapse col ...
- mvc core2.1 Identity.EntityFramework Core 注册 (二)
Startup.cs-> Configure app.UseAuthentication(); //启动验证 Controllers->AccountController.cs 新建 us ...
- mvc core2.1 Identity.EntityFramework Core 用户列表预览 删除 修改 (五)
用户列表预览 Controllers->AccountController.cs [HttpGet] public IActionResult Index() { return View(_us ...
随机推荐
- AI工具5.13
如果想选中上面的很多图形,可以锁定不需要选择的下面的图形.选择需要锁定的对象.“对象”“锁定”“所选对象” “对象”“变换”“再次变换”快捷键“ctrl=d"一般前面有其他操作如“移动”“复 ...
- 【Eclipse使用】在eclipse里添加源文件和Api的方法
一.源代码添加 你的JDK安装目录下%Java_home%/src.zip文件就是源码,解压缩找到对应包下面的类即可. 如果是Eclipse开发,ctr+鼠标左击,出现不了源码的话,在弹出的视图中点击 ...
- Win10系列:JavaScript动画4
上面介绍的动画效果是通过Windows动画库创建的,这里的旋转动画是通过设置页面元素的style对象的相关属性来创建,此动画的效果是将界面元素沿着指定的方向进行旋转.下面介绍style对象的几个常用属 ...
- sys 模块
import sys #环境变量 print(sys.path) #查看已经加载的模块 print(sys.modules) #获取终端调用时的参数 print(sys.argv) #获取解释器的版本 ...
- python-列表,元组,range
# 列表# lst = ["光头强", 1, True, {}, (1, ), {123}, ["周杰伦",[], "周杰", " ...
- 学习Linux系统的方法有很多,适合自己的才是最好
综观现在互联网+的发展以及应用,作为一个从事IT行业的人员,应该懂得Linux占比多大份量,所以说,去掌握Linux是一种相当重要的谋生途径,当然,如果你对它产生情感那更好.这篇文章主要是本人结合自身 ...
- Unity3D中的射线与碰撞检测代码
两种不同写法的射线检测 1.获取鼠标点击的物体 if (Input.GetMouseButtonDown(0)) { Ray ray = MainCamera.ScreenPointToRay(Inp ...
- [javamail]AUTH LOGIN failed;Invalid username or password报错
项目中需要用到javamailAPI,邮箱服务器用的sohu闪电邮,SMTP协议用来发送,赋值代码: Properties props = new Properties(); props.setPro ...
- day03 字符串
今日学习 1.python的基本数据回顾 2.int--数字类型 3.bool值 取值只有True False bool值没有操作 4.字符串 1.python的基本数据回顾 1)int =>整 ...
- 基于UVM的verilog验证(转)
reference:https://www.cnblogs.com/bettty/p/5285785.html Abstract 本文介绍UVM框架,并以crc7为例进行UVM的验证,最后指出常见的U ...