I ran this in cmd.exe dotnet tool install -global dotnet-ef I made sure that I had the powershell Cli tools installed by following this article here by MicroSoft There's a few things that I did where I'm not completely sure which thing exactly was the thing that got it working, but believe this list to be minimal enough for a satisfactory answer. I have just managed to acheive this the first time (mine was with Postgres, but everything should be pretty close as I saw examples for MS Sql and they were very similar, with the only difference if any being useSqlServer or UseNpgsql or similarly trivial differences.Īfter struggling to follow various articles on StackOverflow which were just tiny snippets of the biggest picture I finally managed to get it working nicely, properly and maybe elegantly. ![]() You want these migrations to happen automatically when you start your app.The fact that you want the database and tables created when you run the app, that means your probably more in favour of migration scripts and a code first approach to your workflow rather than a database script with a database first type approach. If you really want to do things properly, then you should probably use Migrate() rather than EnsureCreated() as the latter means that if you want to move towards Migrations then you will have problems. If you need to create you model tables also if in your DB there are some other tables you can use RelationalDatabaseCreator databaseCreator =
0 Comments
Leave a Reply. |