コード例 #1
0
            public SimpleMembershipInitializer()
            {
                Database.SetInitializer<BookShelfContext>(null);

                try
                {
                    using (var context = new BookShelfContext())
                    {
                        if (!context.Database.Exists())
                        {
                            // Create the SimpleMembership database without Entity Framework migration schema
                            ((IObjectContextAdapter)context).ObjectContext.CreateDatabase();
                        }
                    }

                    WebSecurity.InitializeDatabaseConnection("DefaultConnection", "Users", "Id", "Login", autoCreateTables: true);
                }
                catch (Exception ex)
                {
                    throw new InvalidOperationException("The ASP.NET Simple Membership database could not be initialized. For more information, please see http://go.microsoft.com/fwlink/?LinkId=256588", ex);
                }
            }
コード例 #2
0
 public BookShelfRepository()
 {
     _db = new BookShelfContext();
 }