Make Surname not required in my User class
See original GitHub issueHi,
I changed my User class and my AbpUsers table to not require Surname:
User.cs:
public class User : AbpUser<User>
{
public static string CreateRandomPassword()
{
return Guid.NewGuid().ToString("N").Truncate(16);
}
public static User CreateTenantAdminUser(int tenantId, string emailAddress, string password)
{
return new User
{
TenantId = tenantId,
UserName = AdminUserName,
Name = AdminUserName,
Surname = AdminUserName,
EmailAddress = emailAddress,
Password = new PasswordHasher().HashPassword(password)
};
}
/// <summary>Surname of the user.</summary>
[StringLength(32)]
public override string Surname { get; set; }
}
But when I try save a new user without a Surname a DbEntityValidationException is thrown.
What can I do to make this property not required?
Abp version: 10.3.0
Thanks
Issue Analytics
- State:
- Created 7 years ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
Making first name, last name a required attribute rather ...
I'm trying to make sure that the first name and last name field are not optional for the auth User model but I'm...
Read more >What should one fill in the last name column (mandatory) if ...
One person I know who is mononymous (who has only one name, not a given name + a family name), said this when...
Read more >What should the character limit(s) for first/last name inputs ...
In theory the correct answer is no upper limit for name lengths. Allow the user to enter whatever their name is using whatever...
Read more >Name and Surname optional #321
Hello, is it possible to set the User.Name and User.Surname as optional? How can I achieve this? Currently both are marked as Required....
Read more >User.first_name - The Admin
I want to now retrieve the first and/or last name. Not sure if I need to assign the name to a variable, if...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I know it’s an old thread, but had also troubles on this one. Couldn’t get it to work.
@acjh , finally I used your solution. And added some code in the UserManager in order to make it always work
That’s great 😃