我正在使用Nuget包,并连接到现有的Server数据库,其中AspNetUsers表ID列被设置为UniqueIdentifier。
在执行调用以获取用户时,我收到了一个错误:
不能将'IdentityUser`4‘4’上的'Id‘属性设置为'System.Guid’值。必须将此属性设置为'System.String‘类型的非空值。
是否有一种方法可以在代码中设置Id属性,因为我无法修改数据库中的列属性。
下面是我的代码片段:
AuthProvider.cs
public class SimpleAuthorizationServerProvider : OA
恒等式的基本结构
using Microsoft.AspNetCore.Identity;
using System;
namespace Microsoft.AspNetCore.Identity
{
// Represents a user in the identity system
// TKey:
// The type used for the primary key for the user.
public class IdentityUser<TKey> where TKey : IEquatable<
今天,我做了一个令人沮丧的决定,升级到.Not Core 2.0 for Identity Server 4(不像我真的有很多选择)。
在我的旧应用程序中,我在内存用户中添加了一个Test作为测试的默认登录名。它使用了Identity Server 4教程代码,如下所示:
if (!userManager.Users.Any())
{
foreach (var inMemoryUser in Users.Get())
{
var identityUser = new IdentityUser(inMemoryUser.Username)
{
我在使用.NET的项目中使用ASP IndividualAuthentication Core2.1。我需要我的用户表的额外属性,所以我从IdentityUser继承了如下所示:
public class ApplicationUser : IdentityUser
{
[Required]
[DataType(DataType.Text)]
public string Name { get; set; }
[Required]
[DataType(DataType.Text)]
public string LastName { get; s
我想做以下几件事..。当user提交一个新的article时,我希望在我的web应用程序中显示作者(用户)用户名。这就是为什么我需要“连接”这两个并且我希望只有一个DbContext。
现在我这样做了:
public class ApplicationDbContext : IdentityDbContext
{
public DbSet<ApplicationUser> ApplicationUsers { get; set; }
private DbSet<Article> Articles { get; set; } // This line is
我有这门课
public class ApplicationUser : IdentityUser
{
public string Email { get; set; }
public string ConfirmationToken { get; set; }
public bool IsConfirmed { get; set; }
...
}
在DbContext类中,这就是我所做的
public partial class PickerDbContext : IdentityDbContext
{
public PickerDbContext():bas
我想自定义Asp.Net标识3类。
以下是我所做的:
public class MyDbContext : IdentityDbContext<User>
和
public class User : IdentityUser<int>
我也扩展了IdentityUserClaim<int>, IdentityRole<int>, IdentityUserLogin<int> and IdentityUserRole<int>,但是我得到了以下错误:
The type 'User' cannot be use
我有一个扩展的IdentityUser类,其中包含对数据库中另一个实体的引用,但每当我尝试使用UserManager获取用户时,引用的实体总是为空:
我的User类的实现
public class Usuario : IdentityUser
{
public int ClienteID { get; set; }
public virtual Cliente Cliente { get; set; }
}
使用用户的引用属性的控制器
[Authorize]
[HttpGet]
public async Task<Direccion> GET()
{
var
提前谢谢你。这是我的代码:
public class ApplicationUser : IdentityUser
{
public ApplicationUser()
{
}
}
public class AppUserManager : UserManager<ApplicationUser>
{
...
}
public interface IOwinManager
{
UserManager<IdentityUser> UserManager { get; }
}
为什么这不管用?
public class OwinMana
我正在使用IdentityServer 3进行身份验证。我使用asp.net标识框架将用户存储在SQL中。IndentityServer团队为管理员管理用户提供了简单的库。
我遵循并配置了我的应用程序。
我有自己的ApplicationUser和ApplicationUserManager类,如下所示
public class ApplicationUser : Microsoft.AspNet.Identity.EntityFramework.IdentityUser
{
}
public class ApplicationUserManager : Microsoft.AspNet.Id
我正在使用ASP.NET MVC 5创建一个web应用程序。
为了我的应用程序,我创建了一个独立的“网站用户”类,如下所示:
public class WebsiteUser
{
public WebsiteUser()
{
this.Comments = new List<CommentEntityModel>();
}
public int Id { get; set; }
public string Name { get; set; }
public virtual ApplicationUser Identit
我使用Asp.net标识来创建我的成员资格模块,遵循本教程中的,然后我注意到我不能定义INT类型的主键,因为用户模型应该继承IdentityUser,而在IdentityUser类中定义的Id属性是这样的字符串类型,如何解决呢?
namespace Microsoft.AspNet.Identity.EntityFramework
{
public class IdentityUser : IUser
{
public IdentityUser();
public IdentityUser(string userName);
p
我已经创建了一个带有数据库的asp.net MVC网站。我最近增加了一个身份数据库。在我的机器上一切正常。但是,当我在另一台计算机上运行它时,它会给出以下错误:
System.Data.SqlClient.SqlException: 'Invalid object name 'AspNetUsers'.'
,这是我的AccountController
public class AccountController : Controller
{
private UserManager<IdentityUser> user
我有一个像这样的扩展用户类:
public class User : IdentityUser
{
public string Nombre { get; set; }
public string Apellidos { get; set; }
public int DepartamentoID { get; set; }
public Departamento Departamento { get; set; }
}
在我的编辑视图中,我有以下字段定义:
<div class="form-group">
@Html.LabelFor(mode
当我试图使我的用户fr n表AspNetUsers时,用户总是返回null,即使表中有一个用户。
public class ApplicationUser : IdentityUser
{
public int Rating { get; set; }
public string ProfileImageUrl { get; set; }
public DateTime MemberSince { get; set; }
public bool IsActive { get; set; }
}
我想展示的是有作者信息的帖子
public class Post
{
这是我从IdentityUser派生的类:
public class User : IdentityUser
{
public string Extension { get; set; }
}
我是DbContext
public class SecurityDbContext : IdentityDbContext<User>
{
private string connectionString;
private string dbProvider;
public SecurityDbContext(string connectionStr
我正在尝试获取身份框架分配给我的用户的ID的引用,这样我就可以在我的sql数据库中将其作为外键,它当前返回为null:
我的Startup.cs:
public class Startup
{
public void Configuration(IAppBuilder app)
{
HttpConfiguration config = new HttpConfiguration();
ConfigureOAuth(app);
config.Routes.MapHttpRoute("DefaultAPI
我在Asp.net mvc上有点新手,在我的项目中,我将有一个用户注册,一个编辑用户配置文件和查看用户配置文件(创建,编辑,详细信息)的可能性,有没有一种方法,我可以添加新的属性到用户表,以便我可以脚手架用户?在那一刻,我只是这样做的:
public class ApplicationUser : IdentityUser
{
public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser> manager)
{
// Not
我在一个系统中实现ASP.NET身份,在这个系统中使用带有实体框架的用户模型的身份验证,并通过会话在WebApp中进行控制(是的,它是一个遗留系统到web表单中),我们实现了,用身份的ApplicationUser替换了User模型,一切正常。
问题是,有一个通知系统,它基本上是Notification和User模型之间的许多关系,这些通知与系统的其他部分一起保存在Server中,但也在Cache Redis中,以便更快地读取,并且需要序列化以便在其上进行写入。我们移除User模型,然后在Notification模型中添加ICollection of ApplicationUser,反之亦然-
请帮帮我,我正在尝试使用class IdentityUser()创建一个新的用户用户,但是当我在username中添加dash(-)符号时,会出现一个错误。我怎么才能解决这个问题?
var userStore = new UserStore<IdentityUser>();
var manager = new UserManager<IdentityUser>(userStore);
var user = new IdentityUser() { UserName = aspNetUsers.Email };
IdentityResult result = manag
我正在制作一个Post表,用户可以在那里写一个标题和消息并发布它。问题是,我的用户来自ApplicationUser : IdentityUser类。我不是百分之百确定如何把用户放在我的桌子上。
所以我有一个模型类:
public class Post
{
public int Id { get; set; }
[Required]
public string title { get; set; }
[Required]
[StringLength(255)]
public string message { get; set; }
我的应用程序中有一个User类
public class User
{
[Required, MinLength(3), MaxLength(10)]
public string FirstName { get; set; }
[MinLength(3), MaxLength(10)]
public string MiddleName { get; set; }
[Required, MinLength(3), MaxLength(10)]
public string LastN
我重新命名了标准标识表:
public class User : IdentityUser
{
//...
public string Name { get; set; }
public string Surname { get; set; }
public DateTime? RegisteredDate { get; set; }
public DateTime? LastLoginDate { get; set; }
//...
}
protected ove