0

I use asp.net core identity (call it A dbcontext) in my project I also have another dbcontext (call B) with its own migrations. After publishing to production server, the tables associated to B context were created, but even though I have defined a data seed and initializer for A dbcontext, it does not create the tables for identity.

I have to mention that after "CreateIdentitySchema" which is the first migration of identity context, I changed the schema and added another migration (before publishing to server). But it works in my local machine.

In addition I have the following line in my A dbcontext seed:

context.Database.EnsureCreated();

So is there anything wrong with database ?

Update

Both contexts (A and B) use the same database (connection-string). Moreover, I had the EnsureCreated for the B datacontext, then I also added it for A context.

And the error I get is : Invalidobject name "SchemaName.AspNetRoles"

Babak Fakhriloo
  • 2,076
  • 4
  • 44
  • 80
  • Possible duplicate of [How and where to call Database.EnsureCreated and Database.Migrate?](https://stackoverflow.com/questions/38238043/how-and-where-to-call-database-ensurecreated-and-database-migrate) – jmoerdyk Oct 09 '19 at 22:30
  • Additional info: https://learn.microsoft.com/en-us/ef/core/managing-schemas/migrations/#apply-migrations-at-runtime – jmoerdyk Oct 09 '19 at 22:32

0 Answers0