runtime error after changing default table prefix
See original GitHub issueI follow the guide to change default prefix, all works fine before I run the web host project. when I start the project, got an error: Invalid object name 'Editions." I found someone has the same issue too: https://gist.github.com/hikalkan/4f8f793c7929a81d300f int the last comment
- Your Abp package version: 4.3.0
- Your base framework: .Net Core.
- Exception message and stack trace if available:
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction)\n at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)\n at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)\n at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()\n at System.Data.SqlClient.SqlDataReader.get_MetaData()\n at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)\n at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds)\n at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior)\n at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.Execute(IRelationalConnection connection, DbCommandMethod executeMethod, IReadOnlyDictionary
2 parameterValues)\n at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.ExecuteReader(IRelationalConnection connection, IReadOnlyDictionary2 parameterValues)\n at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable
1.Enumerator.BufferlessMoveNext(DbContext _, Boolean buffer)\n at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.Execute[TState,TResult](TState state, Func3 operation, Func
3 verifySucceeded)\n at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable1.Enumerator.MoveNext()\n at System.Linq.Enumerable.TryGetFirst[TSource](IEnumerable
1 source, Boolean& found)\n at lambda_method(Closure )\n at Microsoft.EntityFrameworkCore.Query.Internal.LinqOperatorProvider.ResultEnumerable1.GetEnumerator()\n at Microsoft.EntityFrameworkCore.Query.Internal.LinqOperatorProvider._TrackEntities[TOut,TIn](IEnumerable
1 results, QueryContext queryContext, IList1 entityTrackingInfos, IList
1 entityAccessors)+MoveNext()\n at Microsoft.EntityFrameworkCore.Query.Internal.LinqOperatorProvider.ExceptionInterceptor1.EnumeratorExceptionInterceptor.MoveNext()\n at System.Linq.Enumerable.TryGetFirst[TSource](IEnumerable
1 source, Boolean& found)\n at System.Linq.Enumerable.First[TSource](IEnumerable1 source)\n at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.<>c__DisplayClass15_1
1.<CompileQueryCore>b__0(QueryContext qc)\n at System.Linq.Queryable.FirstOrDefault[TSource](IQueryable1 source, Expression
1 predicate)\n at NewiNOC.EntityFrameworkCore.Seed.Host.DefaultEditionCreator.CreateEditions() in /Volumes/project/aspnet-core/src/NewiNOC.EntityFrameworkCore/EntityFrameworkCore/Seed/Host/DefaultEditionCreator.cs:line 25\n
- Steps needed to reproduce the problem.
- add following code to dbcontext protected override void OnModelCreating(ModelBuilder modelBuilder) { //use Noc as default prefix for default tables base.OnModelCreating(modelBuilder); modelBuilder.ChangeAbpTablePrefix<Tenant, Role, User>(“Noc”); }
- dotnet ef migrations add chagne_table_names
- drop database and use migrator create whole new database
- run the web host project
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (3 by maintainers)
Top GitHub Comments
Thanks, I’ve removed all my migrations, and re-migrated the whole database, after the operation, the error disappeared.
Could you share your project if you are still having this problem ? If not, could you share reproduction steps ? Everything seems normal in your case.
By the way, are you sure that your app is using the correct database ?