diff --git a/src/Umbraco.Core/Persistence/Migrations/Initial/BaseDataCreation.cs b/src/Umbraco.Core/Persistence/Migrations/Initial/BaseDataCreation.cs index 1389017d18..e68ca4947d 100644 --- a/src/Umbraco.Core/Persistence/Migrations/Initial/BaseDataCreation.cs +++ b/src/Umbraco.Core/Persistence/Migrations/Initial/BaseDataCreation.cs @@ -94,7 +94,6 @@ namespace Umbraco.Core.Persistence.Migrations.Initial private void CreateUmbracNodeData() { - _database.Execute(new Sql("SET IDENTITY_INSERT [umbracoNode] ON ")); _database.Insert("umbracoNode", "id", false, new NodeDto { NodeId = -1, Trashed = false, ParentId = -1, UserId = 0, Level = 0, Path = "-1", SortOrder = 0, UniqueId = new Guid("916724a5-173d-4619-b97e-b9de133dd6f5"), Text = "SYSTEM DATA: umbraco master root", NodeObjectType = new Guid("ea7d8624-4cfe-4578-a871-24aa946bf34d"), CreateDate = DateTime.UtcNow }); _database.Insert("umbracoNode", "id", false, new NodeDto { NodeId = -20, Trashed = false, ParentId = -1, UserId = 0, Level = 0, Path = "-1,-20", SortOrder = 0, UniqueId = new Guid("0F582A79-1E41-4CF0-BFA0-76340651891A"), Text = "Recycle Bin", NodeObjectType = new Guid("01BB7FF2-24DC-4C0C-95A2-C24EF72BBAC8"), CreateDate = DateTime.UtcNow }); _database.Insert("umbracoNode", "id", false, new NodeDto { NodeId = -21, Trashed = false, ParentId = -1, UserId = 0, Level = 0, Path = "-1,-21", SortOrder = 0, UniqueId = new Guid("BF7C7CBC-952F-4518-97A2-69E9C7B33842"), Text = "Recycle Bin", NodeObjectType = new Guid("CF3D8E34-1C1C-41e9-AE56-878B57B32113"), CreateDate = DateTime.UtcNow }); @@ -125,74 +124,67 @@ namespace Umbraco.Core.Persistence.Migrations.Initial _database.Insert("umbracoNode", "id", false, new NodeDto { NodeId = 1041, Trashed = false, ParentId = -1, UserId = 0, Level = 1, Path = "-1,1041", SortOrder = 2, UniqueId = new Guid("b6b73142-b9c1-4bf8-a16d-e1c23320b549"), Text = "Tags", NodeObjectType = new Guid("30a2a501-1978-4ddb-a57b-f7efed43ba3c"), CreateDate = DateTime.UtcNow }); _database.Insert("umbracoNode", "id", false, new NodeDto { NodeId = 1042, Trashed = false, ParentId = -1, UserId = 0, Level = 1, Path = "-1,1042", SortOrder = 2, UniqueId = new Guid("0a452bd5-83f9-4bc3-8403-1286e13fb77e"), Text = "Macro Container", NodeObjectType = new Guid("30a2a501-1978-4ddb-a57b-f7efed43ba3c"), CreateDate = DateTime.UtcNow }); _database.Insert("umbracoNode", "id", false, new NodeDto { NodeId = 1043, Trashed = false, ParentId = -1, UserId = 0, Level = 1, Path = "-1,1043", SortOrder = 2, UniqueId = new Guid("1df9f033-e6d4-451f-b8d2-e0cbc50a836f"), Text = "Image Cropper", NodeObjectType = new Guid("30a2a501-1978-4ddb-a57b-f7efed43ba3c"), CreateDate = DateTime.UtcNow }); - _database.Execute(new Sql("SET IDENTITY_INSERT [umbracoNode] OFF;")); } private void CreateCmsContentTypeData() { - _database.Insert(new ContentTypeDto { PrimaryKey = 532, NodeId = 1031, Alias = "Folder", Icon = "folder.gif", Thumbnail = "folder.png", IsContainer = true, AllowAtRoot = true }); - _database.Insert(new ContentTypeDto { PrimaryKey = 533, NodeId = 1032, Alias = "Image", Icon = "mediaPhoto.gif", Thumbnail = "mediaPhoto.png" }); - _database.Insert(new ContentTypeDto { PrimaryKey = 534, NodeId = 1033, Alias = "File", Icon = "mediaFile.gif", Thumbnail = "mediaFile.png" }); + _database.Insert("cmsContentType", "pk", false, new ContentTypeDto { PrimaryKey = 532, NodeId = 1031, Alias = "Folder", Icon = "folder.gif", Thumbnail = "folder.png", IsContainer = true, AllowAtRoot = true }); + _database.Insert("cmsContentType", "pk", false, new ContentTypeDto { PrimaryKey = 533, NodeId = 1032, Alias = "Image", Icon = "mediaPhoto.gif", Thumbnail = "mediaPhoto.png" }); + _database.Insert("cmsContentType", "pk", false, new ContentTypeDto { PrimaryKey = 534, NodeId = 1033, Alias = "File", Icon = "mediaFile.gif", Thumbnail = "mediaFile.png" }); } private void CreateUmbracoUserData() { - _database.Execute(new Sql("SET IDENTITY_INSERT [umbracoUser] ON ")); _database.Insert("umbracoUser", "id", false, new UserDto { Id = 0, Disabled = false, NoConsole = false, Type = 1, ContentStartId = -1, MediaStartId = -1, UserName = "Administrator", Login = "admin", Password = "default", Email = "", UserLanguage = "en", DefaultPermissions = null, DefaultToLiveEditing = false }); - _database.Execute(new Sql("SET IDENTITY_INSERT [umbracoUser] OFF;")); } private void CreateUmbracoUserTypeData() { - _database.Insert(new UserTypeDto { Id = 1, Alias = "admin", Name = "Administrators", DefaultPermissions = "CADMOSKTPIURZ:5F" }); - _database.Insert(new UserTypeDto { Id = 2, Alias = "writer", Name = "Writer", DefaultPermissions = "CAH:F" }); - _database.Insert(new UserTypeDto { Id = 3, Alias = "editor", Name = "Editors", DefaultPermissions = "CADMOSKTPUZ:5F" }); - _database.Insert(new UserTypeDto { Id = 4, Alias = "translator", Name = "Translator", DefaultPermissions = "AF" }); + _database.Insert("umbracoUserType", "id", false, new UserTypeDto { Id = 1, Alias = "admin", Name = "Administrators", DefaultPermissions = "CADMOSKTPIURZ:5F" }); + _database.Insert("umbracoUserType", "id", false, new UserTypeDto { Id = 2, Alias = "writer", Name = "Writer", DefaultPermissions = "CAH:F" }); + _database.Insert("umbracoUserType", "id", false, new UserTypeDto { Id = 3, Alias = "editor", Name = "Editors", DefaultPermissions = "CADMOSKTPUZ:5F" }); + _database.Insert("umbracoUserType", "id", false, new UserTypeDto { Id = 4, Alias = "translator", Name = "Translator", DefaultPermissions = "AF" }); } private void CreateUmbracoUser2AppData() { - _database.Insert(new User2AppDto { UserId = 0, AppAlias = "content" }); - _database.Insert(new User2AppDto { UserId = 0, AppAlias = "developer" }); - _database.Insert(new User2AppDto { UserId = 0, AppAlias = "media" }); - _database.Insert(new User2AppDto { UserId = 0, AppAlias = "member" }); - _database.Insert(new User2AppDto { UserId = 0, AppAlias = "settings" }); - _database.Insert(new User2AppDto { UserId = 0, AppAlias = "users" }); + _database.Insert("umbracoUser2app", "user", false, new User2AppDto { UserId = 0, AppAlias = "content" }); + _database.Insert("umbracoUser2app", "user", false, new User2AppDto { UserId = 0, AppAlias = "developer" }); + _database.Insert("umbracoUser2app", "user", false, new User2AppDto { UserId = 0, AppAlias = "media" }); + _database.Insert("umbracoUser2app", "user", false, new User2AppDto { UserId = 0, AppAlias = "member" }); + _database.Insert("umbracoUser2app", "user", false, new User2AppDto { UserId = 0, AppAlias = "settings" }); + _database.Insert("umbracoUser2app", "user", false, new User2AppDto { UserId = 0, AppAlias = "users" }); } private void CreateCmsMacroPropertyTypeData() { - _database.Insert(new MacroPropertyTypeDto { Id = 3, Alias = "mediaCurrent", RenderAssembly = "umbraco.macroRenderings", RenderType = "media", BaseType = "Int32" }); - _database.Insert(new MacroPropertyTypeDto { Id = 4, Alias = "contentSubs", RenderAssembly = "umbraco.macroRenderings", RenderType = "content", BaseType = "Int32" }); - _database.Insert(new MacroPropertyTypeDto { Id = 5, Alias = "contentRandom", RenderAssembly = "umbraco.macroRenderings", RenderType = "content", BaseType = "Int32" }); - _database.Insert(new MacroPropertyTypeDto { Id = 6, Alias = "contentPicker", RenderAssembly = "umbraco.macroRenderings", RenderType = "content", BaseType = "Int32" }); - _database.Insert(new MacroPropertyTypeDto { Id = 13, Alias = "number", RenderAssembly = "umbraco.macroRenderings", RenderType = "numeric", BaseType = "Int32" }); - _database.Insert(new MacroPropertyTypeDto { Id = 14, Alias = "bool", RenderAssembly = "umbraco.macroRenderings", RenderType = "yesNo", BaseType = "Boolean" }); - _database.Insert(new MacroPropertyTypeDto { Id = 16, Alias = "text", RenderAssembly = "umbraco.macroRenderings", RenderType = "text", BaseType = "String" }); - _database.Insert(new MacroPropertyTypeDto { Id = 17, Alias = "contentTree", RenderAssembly = "umbraco.macroRenderings", RenderType = "content", BaseType = "Int32" }); - _database.Insert(new MacroPropertyTypeDto { Id = 18, Alias = "contentType", RenderAssembly = "umbraco.macroRenderings", RenderType = "contentTypeSingle", BaseType = "Int32" }); - _database.Insert(new MacroPropertyTypeDto { Id = 19, Alias = "contentTypeMultiple", RenderAssembly = "umbraco.macroRenderings", RenderType = "contentTypeMultiple", BaseType = "Int32" }); - _database.Insert(new MacroPropertyTypeDto { Id = 20, Alias = "contentAll", RenderAssembly = "umbraco.macroRenderings", RenderType = "content", BaseType = "Int32" }); - _database.Insert(new MacroPropertyTypeDto { Id = 21, Alias = "tabPicker", RenderAssembly = "umbraco.macroRenderings", RenderType = "tabPicker", BaseType = "String" }); - _database.Insert(new MacroPropertyTypeDto { Id = 22, Alias = "tabPickerMultiple", RenderAssembly = "umbraco.macroRenderings", RenderType = "tabPickerMultiple", BaseType = "String" }); - _database.Insert(new MacroPropertyTypeDto { Id = 23, Alias = "propertyTypePicker", RenderAssembly = "umbraco.macroRenderings", RenderType = "propertyTypePicker", BaseType = "String" }); - _database.Insert(new MacroPropertyTypeDto { Id = 24, Alias = "propertyTypePickerMultiple", RenderAssembly = "umbraco.macroRenderings", RenderType = "propertyTypePickerMultiple", BaseType = "String" }); - _database.Insert(new MacroPropertyTypeDto { Id = 25, Alias = "textMultiLine", RenderAssembly = "umbraco.macroRenderings", RenderType = "textMultiple", BaseType = "String" }); - + _database.Insert("cmsMacroPropertyType", "id", false, new MacroPropertyTypeDto { Id = 3, Alias = "mediaCurrent", RenderAssembly = "umbraco.macroRenderings", RenderType = "media", BaseType = "Int32" }); + _database.Insert("cmsMacroPropertyType", "id", false, new MacroPropertyTypeDto { Id = 4, Alias = "contentSubs", RenderAssembly = "umbraco.macroRenderings", RenderType = "content", BaseType = "Int32" }); + _database.Insert("cmsMacroPropertyType", "id", false, new MacroPropertyTypeDto { Id = 5, Alias = "contentRandom", RenderAssembly = "umbraco.macroRenderings", RenderType = "content", BaseType = "Int32" }); + _database.Insert("cmsMacroPropertyType", "id", false, new MacroPropertyTypeDto { Id = 6, Alias = "contentPicker", RenderAssembly = "umbraco.macroRenderings", RenderType = "content", BaseType = "Int32" }); + _database.Insert("cmsMacroPropertyType", "id", false, new MacroPropertyTypeDto { Id = 13, Alias = "number", RenderAssembly = "umbraco.macroRenderings", RenderType = "numeric", BaseType = "Int32" }); + _database.Insert("cmsMacroPropertyType", "id", false, new MacroPropertyTypeDto { Id = 14, Alias = "bool", RenderAssembly = "umbraco.macroRenderings", RenderType = "yesNo", BaseType = "Boolean" }); + _database.Insert("cmsMacroPropertyType", "id", false, new MacroPropertyTypeDto { Id = 16, Alias = "text", RenderAssembly = "umbraco.macroRenderings", RenderType = "text", BaseType = "String" }); + _database.Insert("cmsMacroPropertyType", "id", false, new MacroPropertyTypeDto { Id = 17, Alias = "contentTree", RenderAssembly = "umbraco.macroRenderings", RenderType = "content", BaseType = "Int32" }); + _database.Insert("cmsMacroPropertyType", "id", false, new MacroPropertyTypeDto { Id = 18, Alias = "contentType", RenderAssembly = "umbraco.macroRenderings", RenderType = "contentTypeSingle", BaseType = "Int32" }); + _database.Insert("cmsMacroPropertyType", "id", false, new MacroPropertyTypeDto { Id = 19, Alias = "contentTypeMultiple", RenderAssembly = "umbraco.macroRenderings", RenderType = "contentTypeMultiple", BaseType = "Int32" }); + _database.Insert("cmsMacroPropertyType", "id", false, new MacroPropertyTypeDto { Id = 20, Alias = "contentAll", RenderAssembly = "umbraco.macroRenderings", RenderType = "content", BaseType = "Int32" }); + _database.Insert("cmsMacroPropertyType", "id", false, new MacroPropertyTypeDto { Id = 21, Alias = "tabPicker", RenderAssembly = "umbraco.macroRenderings", RenderType = "tabPicker", BaseType = "String" }); + _database.Insert("cmsMacroPropertyType", "id", false, new MacroPropertyTypeDto { Id = 22, Alias = "tabPickerMultiple", RenderAssembly = "umbraco.macroRenderings", RenderType = "tabPickerMultiple", BaseType = "String" }); + _database.Insert("cmsMacroPropertyType", "id", false, new MacroPropertyTypeDto { Id = 23, Alias = "propertyTypePicker", RenderAssembly = "umbraco.macroRenderings", RenderType = "propertyTypePicker", BaseType = "String" }); + _database.Insert("cmsMacroPropertyType", "id", false, new MacroPropertyTypeDto { Id = 24, Alias = "propertyTypePickerMultiple", RenderAssembly = "umbraco.macroRenderings", RenderType = "propertyTypePickerMultiple", BaseType = "String" }); + _database.Insert("cmsMacroPropertyType", "id", false, new MacroPropertyTypeDto { Id = 25, Alias = "textMultiLine", RenderAssembly = "umbraco.macroRenderings", RenderType = "textMultiple", BaseType = "String" }); } private void CreateCmsPropertyTypeGroupData() - { - _database.Execute(new Sql("SET IDENTITY_INSERT [cmsPropertyTypeGroup] ON ")); + { _database.Insert("cmsPropertyTypeGroup", "id", false, new PropertyTypeGroupDto { Id = 3, ContentTypeNodeId = 1032, Text = "Image", SortOrder = 1 }); _database.Insert("cmsPropertyTypeGroup", "id", false, new PropertyTypeGroupDto { Id = 4, ContentTypeNodeId = 1033, Text = "File", SortOrder = 1 }); _database.Insert("cmsPropertyTypeGroup", "id", false, new PropertyTypeGroupDto { Id = 5, ContentTypeNodeId = 1031, Text = "Contents", SortOrder = 1 }); - _database.Execute(new Sql("SET IDENTITY_INSERT [cmsPropertyTypeGroup] OFF;")); } private void CreateCmsPropertyTypeData() { - _database.Execute(new Sql("SET IDENTITY_INSERT [cmsPropertyType] ON ")); _database.Insert("cmsPropertyType", "id", false, new PropertyTypeDto { Id = 6, DataTypeId = -90, ContentTypeId = 1032, PropertyTypeGroupId = 3, Alias = "umbracoFile", Name = "Upload image", HelpText = null, SortOrder = 0, Mandatory = false, ValidationRegExp = null, Description = null }); _database.Insert("cmsPropertyType", "id", false, new PropertyTypeDto { Id = 7, DataTypeId = -92, ContentTypeId = 1032, PropertyTypeGroupId = 3, Alias = "umbracoWidth", Name = "Width", HelpText = null, SortOrder = 0, Mandatory = false, ValidationRegExp = null, Description = null }); _database.Insert("cmsPropertyType", "id", false, new PropertyTypeDto { Id = 8, DataTypeId = -92, ContentTypeId = 1032, PropertyTypeGroupId = 3, Alias = "umbracoHeight", Name = "Height", HelpText = null, SortOrder = 0, Mandatory = false, ValidationRegExp = null, Description = null }); @@ -202,25 +194,23 @@ namespace Umbraco.Core.Persistence.Migrations.Initial _database.Insert("cmsPropertyType", "id", false, new PropertyTypeDto { Id = 25, DataTypeId = -92, ContentTypeId = 1033, PropertyTypeGroupId = 4, Alias = "umbracoExtension", Name = "Type", HelpText = null, SortOrder = 0, Mandatory = false, ValidationRegExp = null, Description = null }); _database.Insert("cmsPropertyType", "id", false, new PropertyTypeDto { Id = 26, DataTypeId = -92, ContentTypeId = 1033, PropertyTypeGroupId = 4, Alias = "umbracoBytes", Name = "Size", HelpText = null, SortOrder = 0, Mandatory = false, ValidationRegExp = null, Description = null }); _database.Insert("cmsPropertyType", "id", false, new PropertyTypeDto { Id = 27, DataTypeId = -38, ContentTypeId = 1031, PropertyTypeGroupId = 5, Alias = "contents", Name = "Contents:", HelpText = null, SortOrder = 0, Mandatory = false, ValidationRegExp = null, Description = null }); - _database.Execute(new Sql("SET IDENTITY_INSERT [cmsPropertyType] OFF;")); } private void CreateUmbracoLanguageData() { - _database.Insert(new LanguageDto { Id = 1, IsoCode = "en-US", CultureName = "en-US" }); + _database.Insert("umbracoLanguage", "id", false, new LanguageDto { Id = 1, IsoCode = "en-US", CultureName = "en-US" }); } private void CreateCmsContentTypeAllowedContentTypeData() { - _database.Insert(new ContentTypeAllowedContentTypeDto { Id = 1031, AllowedId = 1031 }); - _database.Insert(new ContentTypeAllowedContentTypeDto { Id = 1031, AllowedId = 1032 }); - _database.Insert(new ContentTypeAllowedContentTypeDto { Id = 1031, AllowedId = 1033 }); + _database.Insert("cmsContentTypeAllowedContentType", "Id", false, new ContentTypeAllowedContentTypeDto { Id = 1031, AllowedId = 1031 }); + _database.Insert("cmsContentTypeAllowedContentType", "Id", false, new ContentTypeAllowedContentTypeDto { Id = 1031, AllowedId = 1032 }); + _database.Insert("cmsContentTypeAllowedContentType", "Id", false, new ContentTypeAllowedContentTypeDto { Id = 1031, AllowedId = 1033 }); } private void CreateCmsDataTypeData() { //TODO Check which of the DataTypeIds below doesn't exist in umbracoNode, which results in a foreign key constraint errors. - _database.Execute(new Sql("SET IDENTITY_INSERT [cmsDataType] ON ")); _database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 1, DataTypeId = -49, ControlId = new Guid("38b352c1-e9f8-4fd8-9324-9a2eab06d97a"), DbType = "Integer" }); _database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 2, DataTypeId = -51, ControlId = new Guid("1413afcb-d19a-4173-8e9a-68288d2a73b8"), DbType = "Integer" }); _database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 3, DataTypeId = -87, ControlId = new Guid("5E9B75AE-FACE-41c8-B47E-5F4B0FD82F83"), DbType = "Ntext" }); @@ -265,29 +255,22 @@ namespace Umbraco.Core.Persistence.Migrations.Initial _database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 22, DataTypeId = 1041, ControlId = new Guid("4023e540-92f5-11dd-ad8b-0800200c9a66"), DbType = "Ntext" }); _database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 23, DataTypeId = 1042, ControlId = new Guid("474FCFF8-9D2D-11DE-ABC6-AD7A56D89593"), DbType = "Ntext" }); _database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 24, DataTypeId = 1043, ControlId = new Guid("7A2D436C-34C2-410F-898F-4A23B3D79F54"), DbType = "Ntext" }); - _database.Execute(new Sql("SET IDENTITY_INSERT [cmsDataType] OFF;")); } private void CreateCmsDataTypePreValuesData() { - _database.Execute(new Sql("SET IDENTITY_INSERT [cmsDataTypePreValues] ON ")); _database.Insert("cmsDataTypePreValues", "id", false, new DataTypePreValueDto { Id = 3, Alias = "", SortOrder = 0, DataTypeNodeId = -87, Value = ",code,undo,redo,cut,copy,mcepasteword,stylepicker,bold,italic,bullist,numlist,outdent,indent,mcelink,unlink,mceinsertanchor,mceimage,umbracomacro,mceinserttable,umbracoembed,mcecharmap,|1|1,2,3,|0|500,400|1049,|true|" }); _database.Insert("cmsDataTypePreValues", "id", false, new DataTypePreValueDto { Id = 4, Alias = "group", SortOrder = 0, DataTypeNodeId = 1041, Value = "default" }); - _database.Execute(new Sql("SET IDENTITY_INSERT [cmsDataTypePreValues] OFF;")); } private void CreateUmbracoRelationTypeData() { - _database.Execute(new Sql("SET IDENTITY_INSERT [umbracoRelationType] ON ")); _database.Insert("umbracoRelationType", "id", false, new RelationTypeDto { Id = 1, Alias = "relateDocumentOnCopy", ChildObjectType = new Guid("C66BA18E-EAF3-4CFF-8A22-41B16D66A972"), ParentObjectType = new Guid("C66BA18E-EAF3-4CFF-8A22-41B16D66A972"), Dual = true, Name = "Relate Document On Copy" }); - _database.Execute(new Sql("SET IDENTITY_INSERT [umbracoRelationType] OFF;")); } private void CreateCmsTaskTypeData() { - _database.Execute(new Sql("SET IDENTITY_INSERT [cmsTaskType] ON ")); _database.Insert("cmsTaskType", "id", false, new TaskTypeDto { Id = 1, Alias = "toTranslate" }); - _database.Execute(new Sql("SET IDENTITY_INSERT [cmsTaskType] OFF;")); } } } \ No newline at end of file diff --git a/src/Umbraco.Core/Persistence/PetaPocoExtensions.cs b/src/Umbraco.Core/Persistence/PetaPocoExtensions.cs index 3848b2eb12..0752e637d9 100644 --- a/src/Umbraco.Core/Persistence/PetaPocoExtensions.cs +++ b/src/Umbraco.Core/Persistence/PetaPocoExtensions.cs @@ -57,7 +57,17 @@ namespace Umbraco.Core.Persistence if (NewTable != null) { var e = new TableCreationEventArgs(); + + //Turn on identity insert if db provider is not mysql + if (DatabaseContext.Current.ProviderName.Contains("MySql") == false && tableDefinition.IsIdentity) + db.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} ON ", SyntaxConfig.SqlSyntaxProvider.GetQuotedTableName(tableName)))); + + //Call the NewTable-event to trigger the insert of base/default data NewTable(tableName, db, e); + + //Turn off identity insert if db provider is not mysql + if (DatabaseContext.Current.ProviderName.Contains("MySql") == false && tableDefinition.IsIdentity) + db.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} OFF;", SyntaxConfig.SqlSyntaxProvider.GetQuotedTableName(tableName)))); } //Loop through foreignkey statements and execute sql diff --git a/src/Umbraco.Core/Persistence/SqlSyntax/ModelDefinitions/DefinitionFactory.cs b/src/Umbraco.Core/Persistence/SqlSyntax/ModelDefinitions/DefinitionFactory.cs index 0d2af3679a..4e5666bbeb 100644 --- a/src/Umbraco.Core/Persistence/SqlSyntax/ModelDefinitions/DefinitionFactory.cs +++ b/src/Umbraco.Core/Persistence/SqlSyntax/ModelDefinitions/DefinitionFactory.cs @@ -28,6 +28,10 @@ namespace Umbraco.Core.Persistence.SqlSyntax.ModelDefinitions var columnAttribute = propertyInfo.FirstAttribute(); string columnName = columnAttribute != null ? columnAttribute.Name : propertyInfo.Name; + //Use PetaPoco's PrimaryKeyAttribute to set Identity property on TableDefinition + var primaryKeyAttribute = modelType.FirstAttribute(); + tableDefinition.IsIdentity = primaryKeyAttribute != null && primaryKeyAttribute.autoIncrement; + //Creates a column definition and adds it to the collection on the table definition var columnDefinition = new ColumnDefinition { diff --git a/src/Umbraco.Core/Persistence/SqlSyntax/ModelDefinitions/TableDefinition.cs b/src/Umbraco.Core/Persistence/SqlSyntax/ModelDefinitions/TableDefinition.cs index 5148b87b4a..dfdacc1fbe 100644 --- a/src/Umbraco.Core/Persistence/SqlSyntax/ModelDefinitions/TableDefinition.cs +++ b/src/Umbraco.Core/Persistence/SqlSyntax/ModelDefinitions/TableDefinition.cs @@ -13,6 +13,7 @@ namespace Umbraco.Core.Persistence.SqlSyntax.ModelDefinitions } public string TableName { get; set; } + public bool IsIdentity { get; set; } public bool IsPrimaryKeyClustered { get { return ColumnDefinitions.Any(x => x.IsPrimaryKeyClustered); }