{"action":"created","issue":{"url":"https://api.github.com/repos/aspnet/EntityFramework/issues/5269","repository_url":"https://api.github.com/repos/aspnet/EntityFramework","labels_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/5269/labels{/name}","comments_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/5269/comments","events_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/5269/events","html_url":"https://github.com/aspnet/EntityFramework/issues/5269","id":153173685,"number":5269,"title":"Empty GUID is overriden with a new GUID","user":{"login":"chris02031","id":15705822,"avatar_url":"https://avatars.githubusercontent.com/u/15705822?v=3","gravatar_id":"","url":"https://api.github.com/users/chris02031","html_url":"https://github.com/chris02031","followers_url":"https://api.github.com/users/chris02031/followers","following_url":"https://api.github.com/users/chris02031/following{/other_user}","gists_url":"https://api.github.com/users/chris02031/gists{/gist_id}","starred_url":"https://api.github.com/users/chris02031/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chris02031/subscriptions","organizations_url":"https://api.github.com/users/chris02031/orgs","repos_url":"https://api.github.com/users/chris02031/repos","events_url":"https://api.github.com/users/chris02031/events{/privacy}","received_events_url":"https://api.github.com/users/chris02031/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-05-05T06:08:51Z","updated_at":"2016-05-06T19:49:00Z","closed_at":null,"body":"When trying to insert GUID.Empty as a value explicitly the EF framework seems to replace this with a new random GUID.\r\n\r\nIn the query parameters list it appears as a '?'.\r\n\r\nEDIT: The column IS a key, but it is not database generated / seed."},"comment":{"url":"https://api.github.com/repos/aspnet/EntityFramework/issues/comments/217541539","html_url":"https://github.com/aspnet/EntityFramework/issues/5269#issuecomment-217541539","issue_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/5269","id":217541539,"user":{"login":"chris02031","id":15705822,"avatar_url":"https://avatars.githubusercontent.com/u/15705822?v=3","gravatar_id":"","url":"https://api.github.com/users/chris02031","html_url":"https://github.com/chris02031","followers_url":"https://api.github.com/users/chris02031/followers","following_url":"https://api.github.com/users/chris02031/following{/other_user}","gists_url":"https://api.github.com/users/chris02031/gists{/gist_id}","starred_url":"https://api.github.com/users/chris02031/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chris02031/subscriptions","organizations_url":"https://api.github.com/users/chris02031/orgs","repos_url":"https://api.github.com/users/chris02031/repos","events_url":"https://api.github.com/users/chris02031/events{/privacy}","received_events_url":"https://api.github.com/users/chris02031/received_events","type":"User","site_admin":false},"created_at":"2016-05-06T19:49:00Z","updated_at":"2016-05-06T19:49:00Z","body":"My original post was wrong. The column is in fact a key, but not DB generated.\r\n\r\n```\r\n public class Owner\r\n    {\r\n        [Key]\r\n        public Guid OwnerID { get; set; }\r\n\r\n        public string CompanyName { get; set; }\r\n        public string CompanyEmail { get; set; }\r\n\r\n        public virtual Currency DefaultCurrency { get; set; }\r\n\r\n        [ForeignKey(\"DefaultCurrency\")]\r\n        public int? DefaultCurrencyID { get; set; }\r\n\r\n        public virtual IList<TradeUser> Users { get; set; }\r\n        public virtual IList<ChannelAccount> ChannelAccounts { get; set; }\r\n        public virtual IList<Product> Products { get; set; }\r\n        public virtual IList<Payment> Transactions { get; set; }\r\n        public virtual IList<Purchase> Purchases { get; set; }\r\n        public virtual IList<Sale> Sales { get; set; }\r\n        public virtual IList<Supplier> Suppliers { get; set; }\r\n        public virtual IList<Customer> Customers { get; set; }\r\n        public virtual IList<ListingGroup> Listings { get; set; }\r\n        public virtual IList<ShippingManifest> ShipmentManifests { get; set; }\r\n\r\n    }\r\n```\r\n\r\n```\r\nprotected override void OnModelCreating(ModelBuilder builder)\r\n        {\r\n            base.OnModelCreating(builder);\r\n\r\n            var m = builder;\r\n\r\n            m.Entity<Payment>(e =>\r\n            {\r\n                e.Property(f => f.LocalTransactionID).HasMaxLength(18);\r\n                e.HasIndex(f => f.LocalTransactionID).HasName(\"IX_Transaction_LocalID\");\r\n            });\r\n\r\n            m.Entity<FinanceAccount>(e =>\r\n            {\r\n                e.Property(f => f.RowVersion).ValueGeneratedOnAddOrUpdate().IsConcurrencyToken();\r\n            });\r\n\r\n            m.Entity<ProductSuppliers>(e =>\r\n            {\r\n                e.HasKey(f => new { f.ProductID, f.SupplierID });\r\n                e.HasOne(f => f.Product).WithMany(f => f.Suppliers).HasForeignKey(f => f.ProductID);\r\n                e.HasOne(f => f.Supplier).WithMany(f => f.Products).HasForeignKey(f => f.SupplierID);\r\n            });\r\n\r\n            m.Entity<Product>(e =>\r\n            {\r\n                e.HasMany(f => f.Components).WithOne(f => f.Product).HasForeignKey(f => f.ProductID);\r\n            });\r\n\r\n            m.Entity<ProductComponent>(e =>\r\n            {\r\n                e.HasKey(f => new { f.ProductID, f.ChildID });\r\n                e.HasOne(f => f.Product).WithMany(f => f.Components).HasForeignKey(f => f.ProductID);\r\n                e.HasOne(f => f.Child).WithMany(f => f.PartOf).HasForeignKey(f => f.ChildID);\r\n            });\r\n\r\n\r\n            foreach (var relationship in m.Model.GetEntityTypes().SelectMany(e => e.GetForeignKeys()))\r\n            {\r\n                relationship.DeleteBehavior = DeleteBehavior.Restrict;\r\n            }\r\n        }\r\n```\r\n\r\nThis creates a random GUID as the key where EF6 used the literal empty GUID.\r\n\r\n```\r\nvar owner = new Owner { OwnerID = Guid.Empty, CompanyEmail = \"owner@email.com\", CompanyName = \"Owner\", DefaultCurrencyID = gbp.CurrencyID };\r\n            _DB.Owners.Add(owner);\r\n```"}}