How can i include a new type in a DbContext and create a table for it?

52 Views Asked by At

im trying to figure out if it's possible in Entity Framework Core to create during runtime a new type and include it in a DBContext and create a table in the db. So far i managed to create tables only if i use:

entitiesContext.Database.EnsureDeleted(); entitiesContext.Database.EnsureCreated();

In terms of model, the methods Add or Attach works half way, because in the moment i call SaveChanges() the app breaks with the error the the object doesn't in the db.

I also checked migrations, but a lot of people not recommend to do this on runtime nor in prod environments.

Thanks in advance!

0

There are 0 best solutions below