Base solution for your next web application
Open Closed

Starting Core+Angular Invalid object name 'AbpEditions' #3833


User avatar
0
klawsuc created

I get the following error when starting my app on the server (Core 1.1 + Angular 4 - aspnetzero 4.1.1)

Application startup exception: System.Data.SqlClient.SqlException: Invalid object name 'AbpEditions'.
   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
   at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
   at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()
   at System.Data.SqlClient.SqlDataReader.get_MetaData()
   at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
   at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds)
   at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior)
   at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.Execute(IRelationalConnection connection, String executeMethod, IReadOnlyDictionary`2 parameterValues, Boolean closeConnection)
   at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.ExecuteReader(IRelationalConnection connection, IReadOnlyDictionary`2 parameterValues)
   at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable.Enumerator.BufferlessMoveNext(Boolean buffer)
   at Microsoft.EntityFrameworkCore.Storage.Internal.SqlServerExecutionStrategy.Execute[TState,TResult](Func`2 operation, Func`2 verifySucceeded, TState state)
   at Microsoft.EntityFrameworkCore.Query.QueryMethodProvider.<_ShapedQuery>d__3`1.MoveNext()
   at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source)
   at lambda_method(Closure , QueryContext )
   at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.&lt;&gt;c__DisplayClass20_0`1.<CompileQueryCore>b__0(QueryContext qc)
   at System.Linq.Queryable.FirstOrDefault[TSource](IQueryable`1 source, Expression`1 predicate)
   at SquireLab.Migrations.Seed.Host.DefaultEditionCreator.CreateEditions() in 
...
ClientConnectionId:f35937a1-f012-41ce-b256-9d370b18d9e2
Error Number:208,State:1,Class:16
Hosting environment: Production
Content root path: C:\...
Now listening on: http://localhost:5291
Application started. Press Ctrl+C to shut down.

6 Answer(s)
  • User Avatar
    0
    klawsuc created

    I get the same error when trying to run a fresh copy of Core + Angular 4.4.0.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @klawsuc,

    It seems like you haven't run migrations on your database. You can also publish your Migrator project (because it's .Net Core), configure it's connection string and run it on the server.

    Then your website should work.

  • User Avatar
    0
    klawsuc created

    Thanks for the reply @ismcagdas.

    I ran the *.Migrator project. The database was created and I was able to run the site from VS 2017. When I published the Host project and ran the site on the server, that is when I get the error. Is there something else I have to do on the server? I thought the published application took care of the db setup and seeding.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @klawsuc,

    Published application does not run migrations. You need to also publish your Migrator console application (right click to it on visual studio and click publish) and move it's output to your server and run it on your server database. Then all AspNet Zero tables must be created on your server DB.

    Thanks.

  • User Avatar
    0
    klawsuc created

    Thank you again @ismcagdas! Well that's helpful information. I thought the migration scripts were included in the published app...i.e. something like a check for db structure and updating it accordingly. Do you know if this information exists anywhere in the documentation so I have it for future reference?

  • User Avatar
    0
    alper created
    Support Team

    hi

    you can checkout Getting Started document. There's a info about migrations. <a class="postlink" href="https://aspnetzero.com/Documents/Getting-Started-Core#DocConfigureMigrations">https://aspnetzero.com/Documents/Gettin ... Migrations</a>