giorgos07/Daarto

IdentityBuilderExtensions check null, then uses null value

Opened this issue · 4 comments

The line

if (roleType != null) {
   ...
} else {
   services.TryAddScoped(
                    typeof(IUsersOnlyTable<,,,,>).MakeGenericType(userType, keyType, userClaimType, userLoginType, userTokenType),
                    typeof(UsersTable<,,,,,>).MakeGenericType(userType, keyType, userClaimType, roleType, userLoginType, userTokenType)

will throw an error if roleType is null because roleType is used as an argument in the second call to the MakeGenericType method

I believe the second call should use the userRoleType as the 4th argument, not rollType

typeof(UsersTable<,,,,,>).MakeGenericType(userType, keyType, userClaimType, userRoleType, userLoginType, userTokenType)

yeah i too get this error. New to ASP .NET doing all i can to avoid using that garbage called EntityFramework..but so far no luck..every solution i tried-is not working, including this one... My database have no tables...so how it suppose to work? :)
And when uncommenting code i get error you talking about

       services.AddDefaultIdentity<IdentityUser>()
                    .AddDapperStores();

@Tommixoft - if you use my fork of this project at https://github.com/mcshaz/Daarto it should work. download my fork and import it to your solution as a separate project, link your main app to the above project as a dependency, and uninstall the nuget package. You will still need to run the SQL to create the database and tables before starting your application, and of course have a working database connection string. All the SQL required to set up the DB is under the https://github.com/giorgos07/Daarto/tree/master/misc/database/IdentityDb/dbo/Tables folder.

As an aside, I wouldn't call EF garbage - it has its place, it is simply that the use scenarios are not universal, and reasons for avoiding it include a) a legacy project with lots of complex SQL already written, b) thorough knowledge of SQL and the time learning linq-to-entities would not be worth it to the developer, c) absolute performance, including running queries concurrently is important d) complete control of transaction scope is required.

Thanks @mcshaz , will try, but i gave up and started to use EF + MySQL. and now finally have working Identity. But having now EF im forced to use it in every class... and be slave for it's overloaded rules :) for terrible idea that IDE should generate tables in db and so on. Maybe im old fashioned but i like when i can control EVERY thing, not to give control so plugins and don't even understand how they work :D With dapper you can see SQL query tweak it as you like. make complex queries. Easy. with EF i bet i will have to work HARD to make it do what i want :D
Thanks again.

@Tommixoft - If you do have the energy and want to help others trying to integrate dapper with MySQL, you could script the database schema that has been created for EF identity for MySql (as described at https://stackoverflow.com/questions/17190083/how-to-take-mysql-database-backup-using-mysql-workbench), and then upload the resultant sql to a git repo. Unlike EF, obviously Dapper is not SQL flavour agnostic, and so it is definitely possible that some of the SQL statements in the data access layer of this library do not work without modification.