I've got a multi tenant asp.net mvc app hosted on iis 8. Each tenant has it's own database, an there is one database with tenants metadata like name, database-name...
As ORM i use Entity Framework with Code-First Migrations.
Now I've got a problem when update the application. because when i start the migration, the App is offline for all tenant because, entity framework can't connect to database with different migration version.
When all Databases are migrated i can start the IIS-Website and all Tenants come online again!
Is there a way to achieve such database migration? OR Am I able to host multiple versions of an MVC App on same Domain (perhaps routing per e.g. http-Header or meta Database)?
Related
I am developping an ASP.Net Core application, backed with a PostgreSQL database.
So far, my application is hosted on my personal VPS, but I would like to migrate on Azure, and I don't know how to handle the DB migrations over there.
My database scheme is handled by Entity Framework Core and mapped with POCOs.
As explained in the docs, when I want to change my SQL scheme, I update the POCOs, create a migration C# file through the dotnet ef migration create command, and apply them through the Database.Migrate() command at runtime.
This is defined by Applying migrations at runtime, however as stated:
While productive for local development and testing of migrations, this approach is inappropriate for managing production databases.
There is a paragraph about using SQL Scripts, but nothing really about "How to apply migrations scripts in CI/CD pipeline".
Of course, I had a look to the official tutorial on Microsoft docs about how to deploy and ASP.Net Core app + SQL DB on Azure, but there is nothing about DB migrations (the migrations of the production DB are applied through CLI from local computer ...).
Isn't there a specific service on Azure allowing us to apply the DB migrations?
I know this question is specific neither to Azure, nor to .NET apps, but I was afraid my question would be too "broad".
Also, when looking for "DB migrations" on Google, most results are concerning the migration from a given DB to another (or from a vendor to another), which is not the same.
Many thanks
There isn't a specific service in Azure that manages your DB migrations.
From experience, it's usually managed by generating the migration SQL (dotnet ef migrations script), reviewing it and then running it manually or saving to a file that is then executed as a part of the CI/CD pipeline.
I guess you are looking for Azure Database Migration Service. It has two main mode, online and offline mode depending on your migration strategy.
It is compatible with PostgresSQL et should allow migration to managed Postgres (Single or Flexible Server).
https://azure.microsoft.com/en-us/services/database-migration/#overview
Once your migration is done, you can then point your connection string to your newly migrated DB.
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.
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 am starting to look at the entity framework and especially identity. I am making an API to be used by an ASP.NET website. The problem I am having is I am used to the aspnet_regsql exe that is used by ASP.NET membership. I need to setup my application database so it has the correct tables and procedures for identity but I just cannot find out how too. I can then use the tables to link to my application tables.
So in short how can i setup the identity framework on a SQL server database?
Thanks in advance.
Check out this project: ASP.NET Identity Database (project template), it can help to create and customize ASP.NET Identity Database manually with SSDT.
Using MVC3, VS 2010 and SQL Express, I have been successful getting through a few tutorials. What I'd like to do now is build my own app which will be deployed. Using Code First, I'd like to have my user authentication and data reside in the same database. From what I've read, it is possible, (acceptable?) but so far I have not found any info on how to get my models and membership to map to the same database - I would like to specify a different DB than aspnet.mdf.
For the membership tables you can use the aspnet_regsql.exe tool on the command line.
Specify the database and credentials and it will create the membership tables on that database.
You can point the Entity Framework to the same database.
This way, both membership and EF will be living in the same database.