I have a linq to sql table/class that uses a GUID as both a primary key and as foreign key. This problem came up when factoring some code that previously worked.
The exception generated is
"Operation is not valid due to the current state of the object."
The process I use is as such:
aspnet_User user() = new aspnet_User();
aspnet_user.childTable = new childTable();
.. set some properties
user.Insert() -> my custom method
... @ my custom method
using (mycontext dc = new context() )
{
user.childTable.ID = (Guid)myNewlyCreatedGuid;
}
The exception occurs on the assignment childTable.set_UserId().