Reputation: 13
I'm fairly new to both C#, SQL and databases.
A couple of months ago I created a small project with a database that held about 4 simple tables. Using Entity Framework, I scaffolded a DbContext
and entities for my database. However, that database is now gone (don't ask why) and in order to easily be able to run my project locally I need to recreate that database. The only thing I have is the DbContext
and the generated entity classes.
Ideally I'd like to use that to do some magic with EF code first, but I realized it wasn't that simple.
Is there a easy way to recreate my DB? And if not, how can I easily interpret the DbContext
(the protected override void OnModelCreating()
method) in order to create the database manually, which I'm happy to do since the database is not that big. Only thing is I'm having a hard time mirroring the tables to match how the DbContext
looks and doesn't quite understand how the DbContext
was created.
Upvotes: 1
Views: 40
Reputation: 41819
You can use EF Core Power Tools to generate a SQL CREATE TABLE script from an existing DbContext
Upvotes: 1