Need some documentation for the 2.0.0-beta related to Owin

Jan 24, 2014 at 12:45 PM
I get lot of compiltation error on my 2.0.0-alpha code as for
            app.Use(typeof(IdentityFactoryMiddleware<DbContext, IdentityFactoryOptions<DbContext>>),
                new IdentityFactoryOptions<DbContext>()
                {
                    Provider = new IdentityFactoryProvider<DbContext>()
                    {
                        OnCreate = (options) => createCallback()
                    }
                });
Error 1 Delegate 'System.Func<Microsoft.AspNet.Identity.Owin.IdentityFactoryOptions<System.Data.Entity.DbContext>,Microsoft.Owin.IOwinContext,System.Data.Entity.DbContext>' does not take 1 arguments E:\WebAPI\DatwendoManager\ConnectorManagerRole\Extensions\OwinExtensions.cs 31 36 ConnectorManagerRole
Jan 27, 2014 at 10:04 PM
Mar 10, 2014 at 8:30 PM
Can you please post what you had to change this code to?
i am struggling with the same chunk of code, and don't understand what @suhasbj is telling me in the comment you referenced.
Thanks

Paul
Mar 10, 2014 at 8:41 PM
Edited Mar 10, 2014 at 8:42 PM
I have totally rewritten my code several time since this question including autofac, so I don't totally remember the steps.

Now I have someting as
        app.CreatePerOwinContext(ConnectorDbContext.Create);
        // Configure the UserManager
        app.CreatePerOwinContext<MyUserManager>(MyUserManager.Create);
with
        public static MyUserManager Create(IdentityFactoryOptions<MyUserManager> options,IOwinContext oContext)
        {
            var manager                         = new MyUserManager(new CustomUserStore(oContext.Get<ConnectorDbContext>()));
            manager.UserValidator               = new UserValidator<MyUser, int>(manager)
            {
                AllowOnlyAlphanumericUserNames  = false,
                RequireUniqueEmail              = false // true
            };
            manager.PasswordValidator           = new MinimumLengthValidator(6);
            var dataProtectionProvider          = options.DataProtectionProvider;
            if (dataProtectionProvider != null)
            {
                manager.UserTokenProvider       = new DataProtectorTokenProvider<MyUser,int>(dataProtectionProvider.Create("ASP.NET Identity"));

            }
            return manager;
        }
Hope it could help you....in this desert of informations :)
Mar 10, 2014 at 9:03 PM
Thanks, that seems to have done the trick....not sure yet since i can't build due to one additional error.....maybe you have an idea?

I copied from the Sample that changes the PK to int.....and this function is complaining.
 public static IAppBuilder UseDbContextFactory(this IAppBuilder app, Func<DbContext> createCallback)
        {
            if (app == null)
            {
                throw new ArgumentNullException("app");
            }
            if (createCallback == null)
            {
                throw new ArgumentNullException("createCallback");
            }


            app.Use(
                typeof(IdentityFactoryMiddleware<DbContext, IdentityFactoryOptions<DbContext>>),
                new IdentityFactoryOptions<DbContext>()
                    {
                        Provider = new IdentityFactoryProvider<DbContext>(){ OnCreate = (options) => createCallback() }
                    }
                );
            
            return app;
        }
The error msg is:
Delegate 'System.Func<Microsoft.AspNet.Identity.Owin.IdentityFactoryOptions<System.Data.Entity.DbContext>,Microsoft.Owin.IOwinContext,System.Data.Entity.DbContext>' does not take 1 arguments  
I am still pretty new to this, so i am not really sure what the syntax is even.....so hard to figure out what to change.

Thanks again for your help so far!
Mar 10, 2014 at 9:24 PM
I am not sure you need this code now.
Try removing it.