Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I visually design my database with Entity Framework Core? [closed]

I am wondering myself, how I should design my database scheme (in terms of efficiency and visuality).

I am developing a ASP.NET Core application with Angular 2 and I am using Entity Framework Core ("Microsoft.EntityFrameworkCore": "1.0.0"), since its my favourite ORM. I definitely prefer the SQL Server 2012, but if there are better options for designing my scheme available for other database management systems, I could switch to something else like PostgreSQL.

EntityFrameworkCore however doesn't support designing the DataContext (with all its POCO classes) with the EDMX designer anymore.

Can you give me any advice how I can design my database visually and automatically generate my POCO classes (and maybe also my TypeScript classes)?

Can you recommend me a good tool for designing my scheme? (At least more convenient than SQL Server Management Studio. I liked the EDMX designer)

EDIT 2019-03-28

Since the latest changelog (18.0 Preview 7) of SQL Server Management Studio announced, that Database Diagrams are deprecated, I am really in need of an alternative to visualize my databases, as soon as possible.

EDIT 2019-04-03

Since someone might stumble upon this question and no one provided an answer for my question, yet... Here you go: VS Extension: Entity Developer ORM Designer for LINQ to SQL

EDIT 2019-07-15

From the SSMS 19.1 Changelog:

Database diagrams were added back into SSMS.

like image 256
ˈvɔlə Avatar asked Aug 05 '16 12:08

ˈvɔlə


2 Answers

If you prefer to start with the database, you can use whatever design tools you find most useful for whichever database platform you prefer to create the database, and then use EF commands to scaffold your model and context from the database. You can execute commands from the Package Manager Console just as with migrations in previous versions of EF:

Scaffold-DbContext "Server=yourServer;Database=yourDb;Trusted_Connection=True;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models

The official documentation covers reverse engineering a model from an existing database

like image 62
Mike Brind Avatar answered Oct 08 '22 11:10

Mike Brind


You can scaffold DbContext with enities using dotnet ef dbcontext scaffold command from terminal (console). So you can design DB in whatever way you want and then run scaffold command and you'll get your generated DbContext and classes.

Here's documentation on command: https://docs.efproject.net/en/latest/miscellaneous/cli/dotnet.html#dotnet-ef-dbcontext-scaffold

like image 27
Oleksii Vynnychenko Avatar answered Oct 08 '22 09:10

Oleksii Vynnychenko