Hi, I have problem mapping uniqueidentifier column in DB with Entity in Linq; I get the error :Unable to cast object of type 'System.Guid' to type 'System.String'. More info below: I have a table with primary key as uniqueidentifier. Ex table: UID: uniqueidentifier (Primary Key) LoginName: varchar Email: varchar Fax: varchar Address: varchar .Net code: Generated the dbml file by dragging and dropping the table using VS2008. Code snippet: MyDBDataContext db = new MyDBDataContext(); SecuredUser u = new SecuredUser(); u.UID = Guid.NewGuid(); u.LoginName = "testdbml"; u.EMail = "testdbml@sri.com"; u.Fax = "123-456-7890"; db.SecurityUsers.InsertOnSubmit(u); db.SubmitChanges(); Console.ReadKey(); I am getting the runtime error "Unable to cast object of type 'System.Guid' to type 'System.String'." when the execution comes to db.SubmitChanges(); Is there something that I am doing wrong? Your help is appriciated. Thanks in advance Sri
sree wrote: > Code snippet: > MyDBDataContext db = new MyDBDataContext(); > SecuredUser u = new SecuredUser(); > u.UID = Guid.NewGuid(); > u.LoginName = "testdbml"; > u.EMail = "testdbml@sri.com"; > u.Fax = "123-456-7890"; > db.SecurityUsers.InsertOnSubmit(u); > db.SubmitChanges(); > Console.ReadKey(); > > > I am getting the runtime error "Unable to cast object of type > 'System.Guid' to type 'System.String'." when the execution comes to > db.SubmitChanges(); Sounds like the generated UID property is of type string, have you tried Guid.NewGuid().ToString() instead? Regards Tim. --