I have the following scenario:
At first I need an application (ASP.NET MVC) with different tenants based on the user login. This step is easy to implement and not need to be answered. Let's say the application is deployed as myapp.com.
On top of the Application a "super-admin" or host should be able to create new tenants for the application.
At runtime the super-admin should be able to set a new application like tenant1.myapp.com. In the backend a new database should be created for the tenant.
My target is to build an application one time and for each new customer just create a new tenant like tenant1.myapp.com with a specific database and let them use it.
How could i implement this? Is it possible to create a new database with Entity Framework and run migrations programmatically?
I hope the question is clear enough.
Related
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.
I am a new to MVC and I need some assistance attaching my account details from my SQL database to the account controller.
When you create a MVC project you have the account setting all set up.
I have attached a database and would like to use my database to add/remove users.
How do I go about modifying the current account code to use my database users?
Thanks
Did you create your MVC project from a template? This is always a good place to start I found. It gives you a nice road map to understand how MVC works. I have started from here on a number of projects and just built out from here.
Open a blank web project in VS and then go to the Package Manager then copy this line in the window: http://www.nuget.org/packages/Microsoft.AspNet.Identity.Samples/2.0.0-beta2
There are other templates like this. But this is a good place to start. It primarily deals with Authentication because of the Identity piece but it has th4e basic MVC bit in there that is quite simple.
One way is that you can add field to the userViewModel. This also need to be done for the applicationUser class and then these will bubble through to the tables.
I am not sure if this is what you want but it seems that you are using template with authentication selected. If that is the case you will have asp.net identity authentication and authorization as built in feature in your template. If you don't want to use that in-built authentication you can select none for authentication while creating project and then you can implement you custom authentication in project. For custom authentication you can follow below links
http://www.dotnettricks.com/learn/mvc/custom-authentication-and-authorization-in-aspnet-mvc
https://www.codeproject.com/Articles/1111522/Custom-Authentication-and-Authorization-in-MVC
I'm writing a WPF desktop application using Entity Framework to persist user data. I'm using a code first approach and a new database.
In certain scenarios, I would like to restrict access to the database solely from the application, i.e. no user should be able to log into the database outside of the application (e.g. using Management Studio).
I'm struggling to make this work, and initially thought to have the database implement SQL authorization (as opposed to Windows authorization), and have the application generate a unique password on database create. Only the application will therefore know this password, and so only the application will be able to log in and edit the database.
My question is as follows: is this at all possible, i.e. can I generate the login details to the database from my C# application using Entity Framework? Are there any better solutions to this problem?
Surprisingly I can't find anyone with this particular scenario so hear goes. I'm developing a SAAS style MVC/EF web app. I want to offer each customer their own sub-domain name and isolated database, the domain name will determine the name/connection string for the application's single EF context. So when each customer signs up I'll spin up a new database and redirect them to their sub-domain to log in.
However when I switch connection name at runtime, code first migrations do not fire and provision the new database up to the latest version. I'm guessing this is because EF will only fire migrations once per context type for the lifetime of the app. Any suggestions? could I somehow manually fire migrations at application start for all registered sub-domains/databases?
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