ASP.NET MVC 5 connect to multiple databases - c#

I have an ASP.NET MVC 5 project and I want to add multiple databases. All databases have identity tables and I want two work with databases in same controllers.
Search in YouTube but not found it

Related

Connect multiple Databases to .NET core project via Entity Framework Core using differents schemmas

I am trying to create a .NET core application that connects to multiple databases.
I need 2 different context, one of them will connect to a database and the other context has to connect to multiple databases (with the same schemma).
I've created both context but i have problems chaning the connection string for the second context.
Ex:
I have an api mehtod that recieve the ID of a product and i have to search that product with the first context and then, depending on the token, update that product on a specific database on the second context
You can take two-parameter in DBcontext class.
Check this out:
Connect multiple Databases to .NET core project via Entity Framework Core

Configure .NET CORE MVC App with Authorization roles (2 SqlLite DB's)

I learned about AuthRoles in a .Net Framework MVC App (Here project) working with 2 SqlServer databases (1 for Roles, Users and Passwords...) and the other for the App tables.
Now I'm trying the same in NET CORE with SqlLite, but I don't know how to manage 2 DbContext. How to make migrations to my App DB and let the Roles DB only working for Authentication, Register, etc.
First at all, I follow this tutorial to get in touch with net core and I finished a mvc sample(1 table, no foreign keys). But I hadn't Authentication logic and only the App db.
After that I found this tutorial that works with Roles SqlLite DB but only has 1 DB.(finished sample Here).
Could you explain to me how can I work with authentications in .net core and if it's possible, use 2 bd, 1 for the app and the other for user passwords, roles, etc?
EDIT
Trying with my net Core mvc app, I managed to create a Identity sqlLite.db. and I created from migration another db (App tables), which by now only has user table. But some issues:
The aplication of migration (using --context 'AppDbContext') generates a db with Identity tables that are already generated in the IdentityRolesUsers db, mixed with my app table User.
When registering an user, the AspUsers table (IdentityDb) aren't linked to Users table and the AspUser is created in the IdentityDb.
Here my migrations files(before ef update). Any solution?
Thanks!
For the first question, you can use multiple DbContext in one project for one database or multiple databases. It is simple and straightforward; you should register each DbContext in ConfigureServise separately.
But why you want to separate your 'role Database'?
In the link below, you can learn how to work with Identity in Dotnet core.
https://learn.microsoft.com/en-us/aspnet/core/security/authentication/identity?view=aspnetcore-3.1&tabs=visual-studio

How to create a WebJob for my ASP.NET Core Web Application

I have a Web Application written in ASP.NET Core 1.0 and it is using Identity(Individual User Account) for authentication. Due to the nature of my Web Application I need to do some regular background task updating data in my Entity Framework Tables and in User Account Tables.
Have been searching for this online and it requires me to create a Console Application and deploy it as a WebJob in Azure. My question is how can I setup the console application to access my Entity Framework Tables and Identity Tables?
You can start with creating a .NET Core console application then add entity framework.
Once you have EF you can scaffold the existing database so you can access the tables you created but in order to access Identity tables you should register Identity services and it to manage roles/users.
Have a look at this article explains it in detail WebJob with access to Tables and Identity Services

How to setup a connection to a SQL Server database using ADO.NET in ASP 5 MVC 6

I'm writing a website in ASP.NET 5 MVC 6 and need to setup a connection to a SQL Server database in order to retrieve some data.
Since I have many existing databases with a lot tables that I have to pull data from with small queries, I believe ADO.NET would be easier to work with than Entity Framework.
How should I go about implementing this in ASP.NET 5?
I've tried to follow this tutorial http://www.compilemode.com/2015/09/crud-operations-in-aspnet-mvc-5.html (it's for ASP.NET MVC 5) but at the EmpRepository I was getting errors about the ConfigurationManager not existing in the current context, although I had using System.Configuration; and a reference to the assembly. I've tried everything that was suggested in this The name 'ConfigurationManager' does not exist in the current context post. Same error still remains.
Is there another way of setting up a connection with ADO.NET using ASP.NET 5?

ASP.NET MVC 4, Entity Framework 5 database-first role management and membership integration in same database

I am new to ASP.NET MVC 4 and Entity Framework. I searched for this on google but I didn't get it may be it is my fault.
I am creating new application using previous database. I want to create user account with different roles and access
I want to use same structure for role management which is generated by ASP.NET MVC 4, but it generates different database for that, I don't want in different database, I want to include in same/my database.
Please anyone answer me how to integrate that structure in my database so that I can use same functionality through my database or it is possible to do in database first?
Please help me I am working on it from last 4 days.

Categories