I'm trying to store the asp.net session id in a table/entity and keep getting an error on insert stating the the SessionID field cannot be null. I don't understand why this is happening since I can debug this and see that the entity field SessionID has the 32 char value. Here is the DDL for the table, anyone have any ideas?
Here is the code that I'm using.
protected void Session_Start(Object sender, EventArgs e)
{
WSSessionEntity session = new WSSessionEntity();
session.SessionID = this.Session.SessionID;
session.StartDate = DateTime.Now;
ServiceFactory.GetPersistanceManager().SaveEntity(session);
}
DDL
CREATE TABLE [dbo].[WSSession] (
[SessionID] [char] (32) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[StartDate] [datetime] NOT NULL ,
[UpdateDate] [datetime] NOT NULL
) ON [PRIMARY]
END
GO
ALTER TABLE [dbo].[WSSession] ADD
CONSTRAINT [DF__WSSession__Start__32D8D1C3] DEFAULT (getdate()) FOR [StartDate],
CONSTRAINT [DF__WSSession__Updat__33CCF5FC] DEFAULT (getdate()) FOR [UpdateDate],
CONSTRAINT [PK_WSSession] PRIMARY KEY NONCLUSTERED
(
[SessionID]
) ON [PRIMARY]
GO