2012-09-11 37 views

回答

9

這爲我工作做數據庫第一次,但可能會幫助你,你已經創建了數據庫之後 -

您可以更新表,並使用Server Management Studio中(而不是通過EF)設置的默認值newid()

然後在EF模型中,將StoreGeneratedPatternnone更新爲Identity

2013編輯: 爲了完整起見,在EF 5.0 Codefirst,您可以指定以下數據註釋:

[Key] 
[DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)] 
public Guid TableIdColumn { get; set; }