Last post Aug 31, 2017 01:41 PM by rawkweila
Aug 28, 2017 08:05 AM|rawkweila|LINK
I'm working on an ASP.NET MVC app and use a database which holds records of all our employees. Currently I'm trying to implement a time management system so they should be able to login to the app and check themselves in and out.
Since we're going to calculate their planned / actual hours, I need to link the app users to the db with the employees in it.
Right now I can register on the app but Identity will generate a new ID for me which isn't good.
Is it possible to use the employee ID's from the existing database as AspNetUsers ID's?
My preffered way would be this:
All employees are registered as users already - also if we hire a new employee, his account should be created as soon as he is added to the database (as soon as he gets his ID).
Then a code / password should be generated with which the employee should activate his account on the app, then change his password.
Hope someone can point me in the right direction. If this is even possible....
Thanks in advance
Aug 28, 2017 09:09 AM|XIII|LINK
if I get your question correctly there might be different scenarios possible:
- create your own providers that make use of the custom table and wire that up (likely not the best option but it gives you control over what you want to accomplish)
- create a mapping table where you put the ID of the default membership table and "connect" it to the ID of your custom table
Aug 29, 2017 07:48 AM|Cathy Zou|LINK
Kris provided a good suggestion.
Besides, I think that following links will be helpful for you, you could refer to it:
Aug 29, 2017 11:02 AM|rawkweila|LINK
thanks a lot for your suggestions. The part about a mapping table sounds interesing.
Unfortunately I couldn't really find much information when I googled - The only answers I found put Data Annotations on a specific class.
I don't understand how this will give me the possibility to use the existing ID's for the Identity users.
Would awesome if you could give me some more information about table mapping.
Thank you for your answer. I will take a look at the links you provided
Aug 29, 2017 03:28 PM|XIII|LINK
simply create a table where you have 2 columns, ID membership - ID your internal users table and make that the coupling between both. If someone logs in you can get the ID of the membership table and via the coupling table you can join your other tables
which concerns your user's data.
Potentially even something else: investigate if you can pump the users specifics, with specific ID in the membership table and make use of it. Don't let people have the ability to delete or add new users via the traditional way that ASP.NET provides and
let the membership tables only be filled by a process that also fills up the users table to keep things in sync.
Personally I would likely go for a custom membershipprovider, and there are plenty of examples about on internet on how to accomplish this, and plug that in.
Aug 31, 2017 01:41 PM|rawkweila|LINK
Awesome Kris. Thanks
I'm looking into the custom membershipproviders as suggested :)