Error while restoring external database from Asp.net mvc application

Asked

Viewed 38 times

0

I’m trying to restore a bank SQL that I created on a provider that does not have the option Webdeploy. And my goal is to boot a database using ASP.NET MVC with EntityFramework. Well, when you put the server settings and password, the bank appears in my SQL Management But it was different, in the icon where it usually turns green, is gray follows an image to illustrate better.

inserir a descrição da imagem aqui

By restoring the DB I have one more error, follow the image:

inserir a descrição da imagem aqui

What is this mistake?

How do I solve it?

Taking advantage, while developing the application, with CodeFirst I used the following Connectionstrings in my WebConfig

<connectionStrings>
    <add name="VendasDeTitulos" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=VendasDeTitulos;Integrated Security=True" providerName="System.Data.SqlClient" />
  </connectionStrings>

How will I stay in the configuration to use with the Provider?

1 answer

1

To Connection string it must be so:

<connectionStrings>
  <add name="VendasDeTitulos" connectionString="Data Source=mssql913.umbler.com,5003;Initial Catalog=VendasDeTitulos;User Id=usuario;Password=senha" providerName="System.Data.SqlClient" />
</connectionStrings>

Do not restore the database manually. The application that should do this.

Check whether your Web.config has the following at the time of publication:

<configuration>
  ...
  <entityFramework>
    <contexts>
      <context type="MeuProjeto.Models.MeuProjeto, MeuProjeto" disableDatabaseInitialization="false">
        <databaseInitializer type="System.Data.Entity.MigrateDatabaseToLatestVersion`2[[MeuContexto, MeuProjeto], [Configuration, MeuProjeto]], EntityFramework" />
        </context>
      </contexts>
   </entityFramework>
<configuration>

Or initialize your base by code:

public MeuContexto()
    : base()
{
    Database.SetInitializer<MeuContexto>(new MigrateDatabaseToLatestVersion<MeuContexto, Configuration>());
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.