I have added a new column IsForceLogOff (datatype = Bit). When I update the table in the usual way, everything updates except the newly added bool column.
public static UserErrorStatus UserUpdate(User user, Company company)
{
UserErrorStatus status = UserErrorStatus.Error;
using (OAPDataLayerEntities DbEntity = GetDBContext())
{
try
{
using (TransactionScope transaction = new TransactionScope())
{
user.IsForceLogOff = true;
DbEntity.Users.Attach(user);
DbEntity.ObjectStateManager.ChangeObjectState(user, EntityState.Modified);
DbEntity.SaveChanges();
transaction.Complete();
DbEntity.AcceptAllChanges();
status = UserErrorStatus.Success;
}
}
}
}
Create table statement:
CREATE TABLE [dbo].[User]
(
[UserID] [int] IDENTITY(1,1) NOT NULL,
[AddressID] [int] NULL,
[AccountTypeID] [int] NOT NULL,
[StaffID] [int] NULL,
[SalutationID] [int] NULL,
[FirstName] [nvarchar](50) NOT NULL,
[LastName] [nvarchar](50) NOT NULL,
[EmailAddress] [nvarchar](100) NOT NULL,
[Password] [nvarchar](50) NOT NULL,
[SecurityQuestionID] [int] NOT NULL,
[SecurityAnswer] [nvarchar](50) NOT NULL,
[PhoneNumber1] [nvarchar](50) NULL,
[PhoneNumber2] [nvarchar](50) NULL,
[Fax] [nvarchar](50) NULL,
[CompanyID] [int] NULL,
[DateCreated] [smalldatetime] NOT NULL,
[DateModified] [smalldatetime] NOT NULL,
[DateLastLogin] [smalldatetime] NOT NULL,
[UserIDModified] [int] NULL,
[StatusID] [int] NOT NULL,
[Notes] [ntext] NULL,
[IsForceLogOff] [bit] NOT NULL
)
Refer to the above sql
