数据库中如果用GUID作主键(默认聚簇索引),会产生页面碎片,可以用UUID来解决这个问题:
[DllImport("rpcrt4.dll", SetLastError = true)] private static extern int UuidCreateSequential(out Guid guid); /// <summary> /// 创建有序的 guid。 /// </summary> /// <returns></returns> public static Guid CreateSequentialGuid() { Guid result; UuidCreateSequential(out result); return result; }