2

I have a MVC5 project with individual authentication.

Now I want to move from (localdb)\MSSQLLocalDB to another SQL Server database.

I've tried to change connection string from this :

Data Source=(localdb)\MSSQLLocalDB;Integrated Security=True;Connect
Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False

to this:

Data Source=PC-GABRI;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False

And the application is still using localDB instead of my new SQL Server DB.

I have already migrated the database and roles.

I have also tried to comment all of my connection string form Web.Config but my application is still working and I can login with my "test" user.

I can't find anything on the web about this!

PS.

Related Questions: Switch LocalDB to SQL server db with MVC5

We have the same problem!

UPDATE 1

DB Instance:

Database Instances

Connection String:

enter image description here

The instances are running correctly.

Tell me if you need more info.


UPDATE

This Guide was very useful for me :

https://danieleagle.com/2014/05/setting-up-asp-net-identity-framework-2-0-with-database-first-vs2013-update-2-spa-template/

Follow all the easy steps for move your LocalDB table to SQL server db Table.

1. Inspect the Web.config File Connection String and Connect to Local Database

Change the defaut connection string:

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

To your connection string:

<add name="DefaultConnection" connectionString="Data Source=PC-YWGSB;Initial Catalog=WebApp;user id=admin;password=admin" providerName="System.Data.SqlClient" />

2. Then use the commands for DB Migration "Codefirst"

This is the official guide:

https://learn.microsoft.com/it-it/aspnet/mvc/overview/getting-started/getting-started-with-ef-using-mvc/migrations-and-deployment-with-the-entity-framework-in-an-asp-net-mvc-application

From the Tools menu, select NuGet Package Manager > Package Manager Console. At the PM> prompt enter the following commands:

  1. enable-migrations
  2. add-migration InitialCreate
  3. update-database

The database will be created automatically during migration. If you already have one make sure to backup all tables.

3
  • Could you please post your code plus the full EF configuration? Commented Mar 1, 2019 at 17:31
  • 1
    You need a Server and an instance of the server in the connection string. Open SQL Server Management Studio to get instance of the server. See login window to get instance. Commented Mar 1, 2019 at 17:33
  • I've updated the question! Thanks! Commented Mar 1, 2019 at 17:52

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.