Reputation: 513
I created three of my contexts for my api on asp net core 1.0, then I changed over to 2.0. After changing over I needed to create my db and tables in a new instance of sql server. I updated the db with entity framework and everything worked as expected. Now I have created a fourth context using the same pattern as the other three (it's basically a carbon copy of one of the existing except for the pocos) and I'm getting this error message:
Unable to create an object of type 'MyFourthContext'. Add an implementation of 'IDesignTimeDbContextFactory < MyFourthContext >' to the project, or see https://go.microsoft.com/fwlink/?linkid=851728 for additional patterns supported at design time.
I have since updated one of my existing contexts and updated the db with no errors.
Is there some config I am missing, something that was created in asp net core 1.0 that I need to update? I've seen all the posts suggesting, like the error message states, to implement IDesignTimeDBContextFactory but that seems little hacky and doesn't feel right seeing as I can get my other contexts to work with no issues. I have also followed the steps in this link as others have suggested.
So I guess, to sum up I have two questions:
Thanks in advance for any help!
Upvotes: 1
Views: 82
Reputation: 513
Solved this one myself. It had been a while since I created the original contexts, I just needed to add a new service declaration in Startup.ConfigureServices().
Just thought I'd answer the question in case anyone else comes across the same issue.
Upvotes: 1