views:

657

answers:

2

I have a Dynamic Data Entities Web Application that uses a database with GUIDs as primary keys for tables. All of the GUID fields have the default value set to NEWID() so SQL Server will generate a new GUID for any record. However in my dynamic data web site, in the insert new entry pages the GUID field shows up and it is expected for the user to enter data. How could I prevent the field from being displayed?

+2  A: 

According to MSDN:

"You can hide the primary key as you do any other column by using the Scaffold attribute and setting its value to false. Because automatically generated keys are not recognized, the default Insert page templates do not work with EDM for tables that have automatic primary keys unless you create a partial class for the entity and apply the Scaffold attribute with a value of false."

Also, as an aside it's preferable to use "newsequentialid()" for the default value of Guid if you're using SQL Server 2005 or higher as it's more efficient for inserting.

Turnkey
A: 

That was exactly what I was looking for. Thank You.

iulianchira