Click here to Skip to main content
15,890,282 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have an mvc5 application that is connected to a EF database. Some fields in this database are meant to be autogenerated as declared in SQL, but when used in MVC and upon inserting records, the GUID only contains the value of 0 for all records. How can I resolve this? Any help will be appreciated. Thanks.

What I have tried:

public partial class Store
    {
        public int StoreID { get; set; }
        public int CustomerID { get; set; }
        public string StoreName { get; set; }
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public System.Guid StoreUID { get; set; }
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public int StoreNumber { get; set; }
        public string StoreLogo { get; set; }
        public string StoreLogoPath { get; set; }
        public string StoreAddress { get; set; }
        public string StoreCity { get; set; }
        public string StoreRegion { get; set; }
        public string StoreCountry { get; set; }

        public virtual Customer Customer { get; set; }
    }
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900