This project is read-only.

STEP 5 Error(Sequence contains no elements) in Club Starter Kit v3 Beta 2 Install Docs

Topics: Developer Discussion, Help, Request
Aug 5, 2011 at 3:21 AM

Hi,

In the ClubStarterKit v3 Preview, when we follow the instruction to run the application, the first 4 steps go smoothly except fifth step into Global.asax file.

          The CODE:

  using (var scope = new ClubStarterKit.Core.DataAccess.UnitOfWorkScope())
            {
                var role = new ClubStarterKit.Domain.Role
                {
                    RoleName = Constants.AdminRole
                };
                scope.UnitOfWork.RepositoryFor<ClubStarterKit.Domain.Role>().Save(role);
                scope.Commit();
            }

            using (var scope = new ClubStarterKit.Core.DataAccess.UnitOfWorkScope())
            {
                var user = scope.UnitOfWork.RepositoryFor<ClubStarterKit.Domain.User>().First(u => u.Username == "akbar]");
                var role = scope.UnitOfWork.RepositoryFor<ClubStarterKit.Domain.User>().First(r => r.RoleName == Constants.AdminRole);

                var userinrole = new ClubStarterKit.Domain.UserInRole
                {
                    User = user,
                    Role = role
                };
                scope.UnitOfWork.RepositoryFor<ClubStarterKit.Domain.UserInRole>().Save(userinrole);

                scope.Commit();
            }
        }

        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
            routes.IgnoreRoute("favicon.ico");

            // register routes from the registrants
            new BinPartLoader<IRouteRegistrant>().WithAssemblyOf<CskApplication>()
                                                 .Items
                                                 .Foreach(r => r.Register(routes));

            // because this mapping needs to be last
            // this mapping MUST be after all registrant 
            // registrations
            routes.MapRouteLowercase(
                "Default",
                "{controller}/{action}/{id}",
                new { controller = "Home", action = "Index", id = "" }
            );
        }
    }
}

 

 

 I receveid this two errors:

Error 1 'ClubStarterKit.Core.DataAccess.IRepository<ClubStarterKit.Domain.User>' does not contain a definition for 'First' and no extension method 'First' accepting a first argument of type 'ClubStarterKit.Core.DataAccess.IRepository<ClubStarterKit.Domain.User>' could be found (are you missing a using directive or an assembly reference?) C:\Documents and Settings\Administrator\Desktop\CMSKIT\clubstarterkit v3 preview\ClubStarterKit.Web\Global.asax.cs 56 89 ClubStarterKit.Web

Error 2 'ClubStarterKit.Core.DataAccess.IRepository<ClubStarterKit.Domain.User>' does not contain a definition for 'First' and no extension method 'First' accepting a first argument of type 'ClubStarterKit.Core.DataAccess.IRepository<ClubStarterKit.Domain.User>' could be found (are you missing a using directive or an assembly reference?) C:\Documents and Settings\Administrator\Desktop\CMSKIT\clubstarterkit v3 preview\ClubStarterKit.Web\Global.asax.cs 57 89 ClubStarterKit.Web

 

Then I  Added "using System.Linq;"  for first error and for second  I changed the
 var user = scope.UnitOfWork.RepositoryFor<ClubStarterKit.Domain.User>()

                                 To

var user = scope.UnitOfWork.RepositoryFor<ClubStarterKit.Domain.Role>()  

But again I am receiving the error in Global.asax in   <ClubStarterKit.Domain.User>().First(u => u.Username == "akbar]");   where it errors    Sequence contains no elements
The application runs but with no administrative privilege, I have tried Asp.net Configuration and it looks the membership is not enabled  in this application.
 Is there a way to make a user as Admin?   

 

Thanks, 

Akbar

 

 

Aug 29, 2011 at 6:32 PM

Apologies for digging up this ancient post, but I had the same problem as you and managed to fix it by following your advice of adding the System.Linq and the final error on:

Global.asax in   <ClubStarterKit.Domain.User>().First(u => u.Username == "akbar]");   where it errors    Sequence contains no elements

Problem seems to be with the username containing " ] ". It now works and the database table "dbo.UserInRole" is updated accordingly.

I tested this and the admin user is able to add events and posts, great! :)

Hope this helps someone with the same error