sivehinvare
New Member
So I am trying to build Custom membership using EF. I dont really know what i am doing but it has gone fairly smooth so far. I am on the Database Initializer step where i am trying to dump data into the database soon as the project runs. My class \[code\]Application.cs\[/code\] uses a GUID as a primary key as seen below. I am trying to figure out how i can add that GUID into the database. I don't know if this is possible but this is what i am trying to do. I took the default login's Database you get when you make a normal web application project in VS 2012 and trying to recreate that database using EF Code First(For practice). This is what i got so far. Class \[code\]public class Applications { [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public Guid ApplicationId { get; set; } [StringLength(125)] public string ApplicationName { get; set; } }\[/code\]Intializer to dump data into db on build(not including Seed.) \[code\] private static List<Applications> addApplications() { var apps = new List<Applications> { new Applications { ApplicationId = Guid.NewGuid(), ApplicationName = "Test Login" } }; return apps; } private static List<Memberships> addMemberships() { var mem = new List<Memberships> { new Memberships { UserId = Guid.NewGuid(), ApplicationId = ?, // How can this guid Match the one in // in ApplicationId for the Application Table? } }; return mem; }\[/code\]I get "Invalid Initializer member declarator". The problem i face is that I need the GUIDS to be the same for \[code\]ApplicationId\[/code\] across multiple tables. I don't even know if this is possible or right?I got a feeling I have to share it somehow maybe like\[code\] Guid AppId; AppId = Guid.NewGuid();\[/code\]