Base solution for your next web application
Open Closed

Unable to run update-database #119


User avatar
0
dipole created

I downloaded the template project and installed AbpZero module. I created the classes as shown in the link <a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate/blob/master/doc/WebSiteContents/zero/installation.html">https://github.com/aspnetboilerplate/as ... ation.html</a>

I successfuly ran add-migration but on running update-database, I keep getting an error about not being able to connect to the database. I have added the connection string to the app.config file of the .entityframework project with no success. I also added the connection string to the DatModule pre-initialize method with no luck. It appears to be trying to use SQLEXPRESS which I do ont have installed I have an SQLServer instance.

PM> update-database -Verbose
Using StartUp project 'ProcPlanet.Core'.
Using NuGet project 'ProcPlanet.EntityFramework'.
Specify the '-Verbose' flag to view the SQL statements being applied to the target database.
Target database is: 'Default' (DataSource: .\SQLEXPRESS, Provider: System.Data.SqlClient, Origin: Convention).
System.Data.SqlClient.SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)

How can I get it to use the connection string. Any help will be appreciated.


4 Answer(s)
  • User Avatar
    0
    mc xie created

    I can see something wrong with you connect string, please check your connect string and you access right to your SQL server.

  • User Avatar
    0
    hikalkan created
    Support Team

    I advice always to set connection string in Update-Database command. This is the command I execute to update database:

    Update-Database -ConnectionString "Server=localhost; Database=MY_DATABASE; User=sa; Password=MY_PASSWORD" -ConnectionProviderName "System.Data.SqlClient" -Verbose -ProjectName "MY_PROJECT.EntityFramework"

  • User Avatar
    0
    dipole created

    Thank you hikalkan. I have been able to update the database. Keep up the great work you are doing. It's a real life saver.

  • User Avatar
    0
    hikalkan created
    Support Team

    Thanks :)