I am trying to set a unique identifier in my customer table from the unique identifer from my membership table (asp.net membership).
However I am getting a null reference exception when doing so. This is the code.
Customer customer = db.Customers.SingleOrDefault(c => c.Id == Convert.ToInt32(formValues["CustomerId"]));
Guid userId = new Guid(user.ProviderUserKey.ToString());
customer.UserId = userId;
It crashes on the last line.
I have tried different settings in my Customer table on the database and in the LINQ to SQL model but I keep getting this.
Anyone know why?
Thanks