Skip to content
This repository has been archived by the owner on Aug 27, 2019. It is now read-only.

Think about how we deal with schema changes #5

Closed
brockallen opened this issue Aug 28, 2014 · 6 comments
Closed

Think about how we deal with schema changes #5

brockallen opened this issue Aug 28, 2014 · 6 comments

Comments

@brockallen
Copy link
Member

Also need to provide a way for a host to specify the Initializer policy. I don't like it in the ServiceFactory ctor.

@FunctionallyLiterate
Copy link

Would it be possible to give the host control of the initializer similar to the asp.net identity plugin? I'm currently using both the entity framework plugin and the asp.net identity one. I really like that I have the ability to customize the schema of the user and roles tables and add a few additional columns. It would be nice to have the same ability with the config database in case we want to associate custom tables with the standard config tables.

@brockallen
Copy link
Member Author

Yes, agreed. This issue is meant to track that and I'd like to rework it more like I've done for the identity stuff.

@promontis
Copy link

Currently trying to work with this assembly. However, my schema is not yet up to date!

Having worked a lot with EF, I always rely on code first migration. It is far more flexible to the database initializers. Also setting the database initializer in the project itself, is not recommended (atleast not hard-coded like it is now)! Anyhow, when adding the assembly to a project, we can specify the following command to enable migrations:

enable-migrations -ContextAssemblyName Thinktecture.IdentityServer.Core.EntityFramework -ProjectName XXX -ConnectionStringName YYY -StartUpProjectName ZZZ

This would create a migration configuration for this specific dbcontext. From there on, you can add migrations or use automatic migrations to update your schema. Very powerfull and flexible!

However, for this to work you'll need to specify a default constructor for the context. It currently does not have this. I'll try to create a PR if everything is ok.

@brockallen
Copy link
Member Author

Ok, I think I've decided that migrations are going to be left to the consuming application to manage. In the past with other projects, we've tried to do migrations within the assembly/project itself and it's been a nightmare. I just tested and a consuming app can easily manage migrations for the DbContexts in IdSvr.Ef's assembly.

@promontis
Copy link

This is what I would suggest as well 👍

@khalidabuhakmeh
Copy link

@brockallen do you have an example of adding a DB migration to the consuming application? When we try to add one it thinks it needs to regenerate the entire schema of our DbContext.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants