can you please explain to me the difference between having the following:
I am trying to make a sort of "Development workflow" but the docs are not really clear about it.
I found that I should:
add migrations
and ef update
as many times as I change somethingIs this the correct flow to work with Entity Framework Core?
Decorate a class with EF Core attribute such as DataAnnotations VS using the code inside OnModelCreating to define relationships and mapping?
Data Annotations are 'inline', but you mix entities with persistence logic. It's the sweet spot, in my opinion. OnModelCreating
enables you to use the 'Fluent API', which is more powerful and flexible, but/and detaches the persistence logic somewhat from your entities. Sometimes you use a mix of both - data annotations and Fluent API.
Creating a Migration class using dotnet ef migrations add "xyz" VS configuring it into OnModelCreating?
Not sure I understand this. I don't see an alternative to migrations.
The way I work with EF (code-first) is:
Basically a 'migration' is necessary when you want to update the database to be compatible with your new/changed code.
OnModelCreating
is necessary when you have to tell EF how the entities map to a database. You shouldn't confuse the two things.