IdentityServer / IdentityServer3.Admin.EntityFramework

Apache License 2.0
12 stars 30 forks source link

ClientConfigurationDbContext #26

Closed eaba closed 7 years ago

eaba commented 7 years ago

I get the below error using the latest release :

{"message":"An error has occurred.","exceptionMessage":"The model backing the 'ClientConfigurationDbContext'
 context has changed since the database was created. Consider using Code First Migrations to update the
 database (http://go.microsoft.com/fwlink/?LinkId=238269).","exceptionType":"System.InvalidOperationException"
,"stackTrace":"   at System.Data.Entity.CreateDatabaseIfNotExists`1.InitializeDatabase(TContext context
)\r\n   at System.Data.Entity.Internal.InternalContext.<>c__DisplayClassf`1.<CreateInitializationAction
>b__e()\r\n   at System.Data.Entity.Internal.InternalContext.PerformInitializationAction(Action action
)\r\n   at System.Data.Entity.Internal.InternalContext.PerformDatabaseInitialization()\r\n   at System
.Data.Entity.Internal.LazyInternalContext.<InitializeDatabase>b__4(InternalContext c)\r\n   at System
.Data.Entity.Internal.RetryAction`1.PerformAction(TInput input)\r\n   at System.Data.Entity.Internal
.LazyInternalContext.InitializeDatabaseAction(Action`1 action)\r\n   at System.Data.Entity.Internal.LazyInternalContext
.InitializeDatabase()\r\n   at System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType
(Type entityType)\r\n   at System.Data.Entity.Internal.Linq.InternalSet`1.Initialize()\r\n   at System
.Data.Entity.Internal.Linq.InternalSet`1.get_InternalContext()\r\n   at System.Data.Entity.Internal.Linq
.InternalSet`1.get_Local()\r\n   at System.Data.Entity.DbSet`1.get_Local()\r\n   at IdentityServer3.EntityFramework
.DbModelBuilderExtensions.RegisterClientChildTablesForDelete[TClient](DbContext ctx) in c:\\git\\identity
\\server3\\EntityFramework\\Source\\Core.EntityFramework\\Extensions\\DbModelBuilderExtensions.cs:line
 31\r\n   at IdentityServer3.EntityFramework.ClientConfigurationDbContext.ConfigureChildCollections(
) in c:\\git\\identity\\server3\\EntityFramework\\Source\\Core.EntityFramework\\DbContexts\\ClientConfigurationDbContext
.cs:line 40\r\n   at IdentityServer3.Admin.EntityFramework.IdentityAdminCoreManager`4.QueryClientsAsync
(String filter, Int32 start, Int32 count) in c:\\git\\identity\\server3admin\\EntityFramework\\source
\\IdentityServer3.Admin.EntityFramework\\IdentityAdminCoreManager.cs:line 616\r\n   at IdentityAdmin
.Api.Controllers.ClientController.<GetClientsAsync>d__4.MoveNext() in c:\\git\\identity\\server3admin
\\Admin\\source\\Core\\Api\\Controllers\\ClientController.cs:line 83\r\n--- End of stack trace from previous
 location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess
(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification
(Task task)\r\n   at System.Threading.Tasks.System.Web.Http866082.TaskHelpersExtensions.<CastToObject
>d__3`1.MoveNext() in c:\\git\\identity\\server3admin\\Admin\\source\\Core\\Extensions\\PropertyMetadataExtensions
.cs:line 0\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System
.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices
.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Controllers
.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__0.MoveNext() in c:\\git\\identity\\server3admin
\\Admin\\source\\Core\\Extensions\\PropertyMetadataExtensions.cs:line 0\r\n--- End of stack trace from
 previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter
.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification
(Task task)\r\n   at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext
() in c:\\git\\identity\\server3admin\\Admin\\source\\Core\\Extensions\\PropertyMetadataExtensions.cs
:line 0\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System
.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext() in c:\\git\\identity
\\server3admin\\Admin\\source\\Core\\Extensions\\PropertyMetadataExtensions.cs:line 0\r\n--- End of stack
 trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices
.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification
(Task task)\r\n   at System.Web.Http.Filters.ActionFilterAttribute.<ExecuteActionFilterAsyncCore>d__0
.MoveNext() in c:\\git\\identity\\server3admin\\Admin\\source\\Core\\Extensions\\PropertyMetadataExtensions
.cs:line 0\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System
.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices
.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Controllers
.ActionFilterResult.<ExecuteAsync>d__2.MoveNext() in c:\\git\\identity\\server3admin\\Admin\\source\
\Core\\Extensions\\PropertyMetadataExtensions.cs:line 0\r\n--- End of stack trace from previous location
 where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess
(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification
(Task task)\r\n   at System.Web.Http.Filters.AuthorizationFilterAttribute.<ExecuteAuthorizationFilterAsyncCore
>d__2.MoveNext() in c:\\git\\identity\\server3admin\\Admin\\source\\Core\\Extensions\\PropertyMetadataExtensions
.cs:line 0\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System
.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices
.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Controllers
.AuthenticationFilterResult.<ExecuteAsync>d__0.MoveNext() in c:\\git\\identity\\server3admin\\Admin\
\source\\Core\\Extensions\\PropertyMetadataExtensions.cs:line 0\r\n--- End of stack trace from previous
 location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess
(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification
(Task task)\r\n   at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext() in
 c:\\git\\identity\\server3admin\\Admin\\source\\Core\\Extensions\\PropertyMetadataExtensions.cs:line
 0"}

i am running it against IdentityServer3 5.2.3 Thanks

iBoonz commented 7 years ago

Database is not in sync

2016-09-06 14:46 GMT+02:00 Mestical notifications@github.com:

I get the below error using the latest release :

{"message":"An error has occurred.","exceptionMessage":"The model backing the 'ClientConfigurationDbContext' context has changed since the database was created. Consider using Code First Migrations to update the database (http://go.microsoft.com/fwlink/?LinkId=238269).","exceptionType":"System.InvalidOperationException" ,"stackTrace":" at System.Data.Entity.CreateDatabaseIfNotExists1.InitializeDatabase(TContext context )\r\n at System.Data.Entity.Internal.InternalContext.<>c__DisplayClassf1.<CreateInitializationAction

be()\r\n at System.Data.Entity.Internal.InternalContext.PerformInitializationAction(Action action )\r\n at System.Data.Entity.Internal.InternalContext.PerformDatabaseInitialization()\r\n at System .Data.Entity.Internal.LazyInternalContext.b4(InternalContext c)\r\n at System .Data.Entity.Internal.RetryAction1.PerformAction(TInput input)\r\n at System.Data.Entity.Internal .LazyInternalContext.InitializeDatabaseAction(Action1 action)\r\n at System.Data.Entity.Internal.LazyInternalContext .InitializeDatabase()\r\n at System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType (Type entityType)\r\n at System.Data.Entity.Internal.Linq.InternalSet1.Initialize()\r\n at System .Data.Entity.Internal.Linq.InternalSet1.get_InternalContext()\r\n at System.Data.Entity.Internal.Linq .InternalSet1.get_Local()\r\n at System.Data.Entity.DbSet1.get_Local()\r\n at IdentityServer3.EntityFramework .DbModelBuilderExtensions.RegisterClientChildTablesForDelete[TClient](DbContext ctx) in c:\git\identity \server3\EntityFramework\Source\Core.EntityFramework\Extensions\DbModelBuilderExtensions.cs:line 31\r\n at IdentityServer3.EntityFramework.ClientConfigurationDbContext.ConfigureChildCollections( ) in c:\git\identity\server3\EntityFramework\Source\Core.EntityFramework\DbContexts\ClientConfigurationDbContext .cs:line 40\r\n at IdentityServer3.Admin.EntityFramework.IdentityAdminCoreManager4.QueryClientsAsync (String filter, Int32 start, Int32 count) in c:\\git\\identity\\server3admin\\EntityFramework\\source \\IdentityServer3.Admin.EntityFramework\\IdentityAdminCoreManager.cs:line 616\r\n at IdentityAdmin .Api.Controllers.ClientController.<GetClientsAsync>d__4.MoveNext() in c:\\git\\identity\\server3admin \\Admin\\source\\Core\\Api\\Controllers\\ClientController.cs:line 83\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (Task task)\r\n at System.Threading.Tasks.System.Web.Http866082.TaskHelpersExtensions.<CastToObject d__31.MoveNext() in c:\git\identity\server3admin\Admin\source\Core\Extensions\PropertyMetadataExtensions .cs:line 0\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System .Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices .TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers .ApiControllerActionInvoker.d0.MoveNext() in c:\git\identity\server3admin \Admin\source\Core\Extensions\PropertyMetadataExtensions.cs:line 0\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter .ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (Task task)\r\n at System.Web.Http.Filters.ActionFilterAttribute.d5.MoveNext () in c:\git\identity\server3admin\Admin\source\Core\Extensions\PropertyMetadataExtensions.cs :line 0\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System .Web.Http.Filters.ActionFilterAttribute.d5.MoveNext() in c:\git\identity \server3admin\Admin\source\Core\Extensions\PropertyMetadataExtensions.cs:line 0\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices .TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (Task task)\r\n at System.Web.Http.Filters.ActionFilterAttribute.d0 .MoveNext() in c:\git\identity\server3admin\Admin\source\Core\Extensions\PropertyMetadataExtensions .cs:line 0\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System .Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices .TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers .ActionFilterResult.d2.MoveNext() in c:\git\identity\server3admin\Admin\source\ \Core\Extensions\PropertyMetadataExtensions.cs:line 0\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (Task task)\r\n at System.Web.Http.Filters.AuthorizationFilterAttribute.<ExecuteAuthorizationFilterAsyncCore d2.MoveNext() in c:\git\identity\server3admin\Admin\source\Core\Extensions\PropertyMetadataExtensions .cs:line 0\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System .Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices .TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers .AuthenticationFilterResult.d0.MoveNext() in c:\git\identity\server3admin\Admin\ \source\Core\Extensions\PropertyMetadataExtensions.cs:line 0\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (Task task)\r\n at System.Web.Http.Dispatcher.HttpControllerDispatcher.d1.MoveNext() in c:\git\identity\server3admin\Admin\source\Core\Extensions\PropertyMetadataExtensions.cs:line 0"}

i am running it against IdentityServer3 5.2.3 Thanks

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/IdentityServer/IdentityServer3.Admin.EntityFramework/issues/26, or mute the thread https://github.com/notifications/unsubscribe-auth/ACy2xlEqPFpJ5Q_-GR7LmzsJFO7wDw2zks5qnWCtgaJpZM4J1zBN .

eaba commented 7 years ago

@iBoonz at what end? I can not see any migration script for IdentityServer3 5.2.3 which makes me to think the schema are still intact except if @brockallen is yet to update the sample repo with it.

Little guidance will do though! Thanks

madhavabhyankar commented 7 years ago

you could use entity framework to find out what has changed and generate scripts. Add-Migration TestMigration Update-Database -script

eaba commented 7 years ago

Okay to get rid of this issue, since a have my main project working fine and to get the admin project working I created a new IdentityCoreAdminManager class and changed all new ClientConfigurationDbContext to :

public class NewContext : ClientConfigurationDbContext
    {
        public NewContext(string con, string schema)
            : base(con, schema)
        {

        }
        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            Database.SetInitializer<NewContext>(null);
            base.OnModelCreating(modelBuilder);
        }
    }

And it works now and I dont know if it is the best way but I have moved on from the issue!!