How to change standard user identity databse from local db to ms server? RRS feed

  • Question

  • User-171486041 posted

    Summary of the problem I am having:

    When I change connectionstring


    <add name="DefaultConnection" connectionString="Data Source=(LocalDb)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\aspnet-NOSSK-20190628094326.mdf;Initial Catalog=aspnet-NOSSK-20190628094326;Integrated Security=True"
    providerName="System.Data.SqlClient" />


    <add name="myDataBaseEntities" connectionString="metadata=res://*/Models.Model1.csdl|res://*/Models.Model1.ssdl|res://*/Models.Model1.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=DESKTOP-UL1TUIH;initial catalog=myDataBase;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" /></connectionStrings>

    Error I am receiving:

    Server Error in '/' Application.

    The entity type ApplicationUser is not part of the model for the current context.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

    Exception Details: System.InvalidOperationException: The entity type ApplicationUser is not part of the model for the current context.

    Source Error: 

    Line 356:        private bool HasPassword()
    Line 357:        {
    Line 358:            var user = UserManager.FindById(User.Identity.GetUserId());
    Line 359:            if (user != null)
    Line 360:            {

    Source File: C:\Users\zhamb\Source\repos\NOSSK\Controllers\ManageController.cs    Line: 358 

    Please help me!!!

    Friday, June 28, 2019 4:22 AM

All replies

  • User-1174608757 posted

    Hi Zhnambyl,

    According to your description,it has problem in your new connectionstring. It will create database dll when application runs.

    However identity needs  codefirst dll, I think it shows this error because it couldn't find the mapping based on database dll. So I suggest that you could modify your connecting string like  below:

     <add name="jambdbEntitiesapplication"   providerName="System.Data.SqlClient" connectionString="Server=tcp:jambdb.database.windows.net,1433;Initial Catalog=jambdb;Persist Security Info=False;User ID=jambor;Password=***;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;" />

    then you could enable AutomaticMigrationsEnabled = true in Configuration class under Migrations folder.

    Here is the link I hope it could help you.


    Best Regards


    Monday, July 1, 2019 8:14 AM