Use table of the Database, instead of table created when using Individual Authentication with Identity

1

I created an application in Asp.net MVC using Identity and I left checked the option for Visual Studio to create the authentication of individual users for me. It turns out that I just discovered that it creates a .mdf file that contains a database and tables for storing user records. I did not know this and I ended up creating another table for my system with business rules and so on. When I put the application on the server logically, that .mdf file with the database and its tables were not and then I could not use the authentication. From there I've seen that I have a few options:

1 - Create the same exact same tables in the DB that I already use in SQL Server and use the "DefaultConnection" connection for the connection I am using from Entity. For this option, you are giving an error in my application when trying to create user or login (since I put users manually in the DB):

Detalhes da Exceção: System.InvalidOperationException: The entity type ApplicationUser is not part of the model for the current context.

Erro de Origem: 

Linha 74:             // Isso não conta falhas de login em relação ao bloqueio de conta
Linha 75:             // Para permitir que falhas de senha acionem o bloqueio da conta, altere para shouldLockout: true
Linha 76:             var result = await SignInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, shouldLockout: false);
Linha 77:             switch (result)
Linha 78:             {

Arquivo de Origem: c:\Users\sydvagner.franco\Documents\Visual Studio 2013\Projects\LPGPonto\LPGPonto\Controllers\AccountController.cs    Linha: 76 

2 - Try to use both databases for this application. I think it's kind of bizarre, but I'd take it if it was the simplest. In that case I would migrate the DB to SQL Server (I've seen that this is possible, but I have not tried it yet) or would put the .mdf file on the server by changing the Web.config to access that file in place as I put it on the server , rather than in | DataDirectory | as it comes from Default which is the application's App_Data folder (This folder does not appear after the system deploy, so there is no automatically created .mdf file for authentication control).

System Operation

It is an Electronic Point system that has the tables:

  • DAILY
  • HOLIDAY
  • FAIRS
  • FUNCTION
  • EMPLOYEE
  • LOCAL
  • REGISTRY (which stores the IP and time of the dot record).
  • AspNetRoles (I got the script and generated the table equal to the one created by Identity)
  • AspNetUsers (I got the script and generated the table equal to the one created by Identity)
  • Tables generated in BD automatically to control user authentication

  • MigrationHistory
  • AspNetRoles
  • AspNetUsersLogins
  • AspNetUserRoles
  • AspNetUsers
  • I just put the AspNetUsers and AspNetRoles tables because I thought I'd just use those.

        
    asked by anonymous 03.10.2014 / 21:25

    1 answer

    1

    I did the migration (as shown here ) from the database created automatically by Identity to control user authentication on the system for my SQL Server DB server and I am now using both databases for the same application. It was the way it was given for not having done the migration of this bank before and have used that same bank for the general data of my application. So my tip is that whenever someone leaves the option for Identity to create authentication for user, migrate that database to SQL Server and use that same database to insert other application tables, so that you do not need to use 2 bank for the same system.

        
    06.10.2014 / 16:43