AspNetUsers Table recovery - c#

I am building a Web Api which is hosted on Azure. This project has Individual User Account authentication in it.
I have accidentally deleted the AspNetUsers table from my project and I do not know if it is possible to get it back. I have also deleted the _MigrationHistory table so I cannot get it back from there.
Is there any way to retrieve this table or even create a new one with identical columns. It does not matter about the missing User data I just need to be able to Register Users again.
I am using Entity Framework Code First. I tried adding a migration and updating the database but this does not work.
I think creating a new project is a last resort fix but I really don't want to have to do that!

Related

Entity Framework with some table unique and other are different based on client

I am making a middleware project, which have some functionality, which are same for every client. For this I have make many tables, and update migration in every client, issue is, whenever I changed any table on any client based on any condition, I need to update it on another client also.
Let's say I have tables in which User Information, Chatting Modules and Company Information Modules are same and every clients need other information of their customer based on their businesses, so we have to make another tables also. When I changed any table in any client, I have to changed it on other client also. I need a solution where I can make some table unique for every client, and other tables are based on client requirement.
I am using Entity Framework with a code-first approach.
You can create 1 BaseDBContext for common tables. Then for each client, create their own DBContext such as ClientADBContext, ClientBDBContext.
Client and base context can have same connection string, but you need to manually manage the migration scripts. So better to have 2 databases for 2 contexts.

Implement new IdentityServer in .NetCore MVC with existing UserDb

I would like to create a new IdentityServer4 for a .NetCore MVC Project without ASP-Authentication, which gets the users from an existing MS SQL-database.
The user database should not have to be changed, if not necessary.
Unfortunately, previous tutorials could not help me, because a lot has been revised.
What steps are necessary to achieve this?
Hope you can help me,
best regards
The Identity server i am currently working on used to connect to a MsSQL server database that contained legacy users. The identity server itself stored its own tables in its database. I believe the way it worked was it had its on UserDbContext added to the middelwere.
So what we had was.
Identity server database - clients and stuff
Legacy user database - All user data.
Which is close to what you are talking about
services.AddDbContext<UserDbContext>(builder => builder.UseSqlServer(settingsSetup.ConnectionStrings.UserDatabaseConnection));
Everything ran though a custom UserManager.
It no longer runs this way as over the summer i integrated all of the users to Asp .net core identity and the data now resides in the same database as the identity server.
I can dig around in the solution control old branches if you need more info.

How add new column to deployed table in Azure without losing data?

I have already deployed ASP.NET MVC web application with DB in Azure. I use EF Code First.
Now I need to add column to table Users without losing any existing data. Should I use migrations or SQL Server Management Studio or something else? And how should I use it?
I had to do the following:
enable-migrations
add property into the entity I wanted to change
add-migration
deploy

ASP.Net Identity 2.xx with Entity framework code first approach on mysql database

Am building an MVC5 application with Code first approach. The problem i have is that if i run the main migrations for the application models(not for identity models), then the Identity tables cannot be created when the database is already existing and has a __migrationhistory table. If i try to run a query on any of the identity tables, it will return an error that the table doesn't exist. I have searched around but all i could see are the ones talking of adding asp.net identity to an existing database first design.
If i run the identity migrations first before every other thing, it goes well but the main application entity migration will not be effected once the database has been created by the Identity framework, resulting in 'table does not exist' when i try to run any query.
How do i run either the Identity framework migration first and then run the normal entity framwork migration or vice versa. If either can be triggered automatically after the other has completed, it will be fine.
Please any suggestion will be appreciated.

LightSwitch app design

I’m currently working on a LightSwitch (LS) app that will be use for tracking project workload across multiple departments in my organization. I intend on using Windows Authentication (Allow only user and AD sec groups) for my access control. I’ve hit a brick wall in my thought/design process. When approaching this project my first thought was to set up a “Users” table that will be referenced in my other tables when a user performs any DB insert. Heres a basic diagram to help illustrate:.
This is where I’m stuck. When you publish a LS app, you can choose to also publish the SQL DB schema that you designed in LS which i intend on doing. When it publishes the schema, it also includes the popular asp.net membership tables/SP’s. This is where where LS stores the applications users. Because this table isn't created until after the application has been published i can’t reference it in my code. And the reason i would like to reference it, is so when a user does a insert into the WorkLog table, i can use the username/ID. I can also use the username to do Row Level Security (RLS). Anyone have any suggestions on how i can achieve this?
Nutshell: I would like to reference the table that the registered users are stored in so i can use their username/userID in my other tables. I’m open to ANY suggestion at this point
I use a "Users" table to store many details that are not stored in the .net tables such as phone, picture, department,etc. and use the active directory account to compare the user, then use the "Users" properties in the app because the user has already been authenticated. That way, I can add any property to the Users table that I need and I don't need to change the .net tables. For auditing, You can use Beth Massi's blog or this forum link:
http://social.msdn.microsoft.com/Forums/vstudio/en-US/21da645b-93ba-41c9-a224-ea6a74362d15/how-to-create-a-simple-audit-trail-change-log-in-lightswitch-in-c?forum=lightswitch
Scott

Categories

Resources