Good afternoon guys, I'm supporting a project of my company, which is using identity config.
In this I added a deleted call variable in my database and gave an update-database and updated the database with this new variable, but when I start on my system it displays the following message.
The 'Excluido' property on 'ApplicationUser' could not be set to a 'null' value. You must set this property to a non-null value of type 'System.Boolean'.
below this my identity
using System;
using Microsoft.AspNet.Identity;
using Microsoft.AspNet.Identity.EntityFramework;
using System.Data.Entity;
using System.Security.Claims;
using System.Threading.Tasks;
using System.Data.Entity.ModelConfiguration.Conventions;
using System.Linq;
namespace IdentitySample.Models
{
// You can add profile data for the user by adding more properties to your ApplicationUser class, please visit http://go.microsoft.com/fwlink/?LinkID=317594 to learn more.
public class ApplicationUser : IdentityUser
{
public string Nome { get; set; }
public string Cpf { get; set; }
public Guid RegiaoId { get; set; }
public bool Excluido { get; set; }
public string Observacoes { get; set; }
public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser> manager)
{
// Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType
var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);
// Add custom user claims here
return userIdentity;
}
private ApplicationDbContext db = new ApplicationDbContext();
public async Task<bool> GetByCpfAsync(string cpf)
{
var users = db.Users.Where(x => x.Cpf == cpf);
return await users.AnyAsync();
}
public async Task<bool> GetByCpfAsync(string cpf, string id)
{
var users = db.Users.Where(x => x.Cpf == cpf && x.Id != id);
return await users.AnyAsync();
}
}
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
public ApplicationDbContext()
: base("DefaultConnection", throwIfV1Schema: false)
{
}
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
modelBuilder.Conventions.Remove<OneToManyCascadeDeleteConvention>();
modelBuilder.Conventions.Remove<ManyToManyCascadeDeleteConvention>();
modelBuilder.Entity<IdentityUser>()
.ToTable("jud_Users");
modelBuilder.Entity<ApplicationUser>()
.ToTable("jud_Users");
modelBuilder.Entity<IdentityUserRole>()
.ToTable("jud_UserRoles");
modelBuilder.Entity<IdentityUserLogin>()
.ToTable("jud_Logins");
modelBuilder.Entity<IdentityUserClaim>()
.ToTable("jud_Claims");
modelBuilder.Entity<IdentityRole>()
.ToTable("jud_Roles");
}
static ApplicationDbContext()
{
// Set the database intializer which is run once during application start
// This seeds the database with admin user credentials and admin role
Database.SetInitializer<ApplicationDbContext>(new ApplicationDbInitializer());
}
public static ApplicationDbContext Create()
{
return new ApplicationDbContext();
}
}
}
Could anyone help me?