Solucionado (ver solução)
Solucionado
(ver solução)
5
respostas

Problema ao criar tabelas pelo migration

Com os comandos informados no curso a migration...cs fo gerada com sucesso, porem ao dar update no banco e tentar acessar o arquivo.mdf nao foram criadas as tabelas.

5 respostas

Oi Lais!

Você pode postar aqui o resultado do console do Package Manager quando você roda o migration, para analisarmos melhor? Obrigado!

PM> Add-Migration TabelasIniciais Scaffolding migration 'TabelasIniciais'. The Designer Code for this migration file includes a snapshot of your current Code First model. This snapshot is used to calculate the changes to your model when you scaffold the next migration. If you make additional changes to your model that you want to include in this migration, then you can re-scaffold it by running 'Add-Migration TabelasIniciais' again.

A previous migration called 'TabelasIniciais' was already applied to the target database. If you meant to re-scaffold 'TabelasIniciais', revert it by running 'Update-Database -TargetMigration $InitialDatabase', then delete '201703141736396_TabelasIniciais1.cs' and run 'Add-Migration TabelasIniciais' again.

PM> Update-Database Specify the '-Verbose' flag to view the SQL statements being applied to the target database. No pending explicit migrations. Running Seed method. PM>

porem nada é exibidos em tables

Oi Laís, por favor siga esses passos:

  • Rode:
PM> Update-Database -TargetMigration $InitialDatabase
  • Exclua o arquivo '201703141736396_TabelasIniciais1.cs'

  • Rode novamente:

PM> Add-Migration TabelasIniciais

Prezados, executei os comandos , segue a saida no console:

PM> Update-Database -TargetMigration $InitialDatabase Specify the '-Verbose' flag to view the SQL statements being applied to the target database. Target database is already at version 0. PM> Add-Migration TabelasIniciais Re-scaffolding migration 'TabelasIniciais'. PM>

porem ainda nao sao exibidas as tables, dei refresh e nada é exibido

solução!

o problema ocorreu pois a configuração da connectionStrings estava no arquivo web.config incorreto, apos ajuste o projeto funcionou.

Quer mergulhar em tecnologia e aprendizagem?

Receba a newsletter que o nosso CEO escreve pessoalmente, com insights do mercado de trabalho, ciência e desenvolvimento de software