❔ Initializing a relation in Entity Framework Core?
How can I initialize
User
and Blog
with EntityFrameworkCore?12 Replies
This is my DataContext:
Introduction to relationships - EF Core
How to configure relationships between entity types when using Entity Framework Core
u need to have foreign id inside your models and setup OnModelCreating method
Either use IDs, or pass a tracked entity
or
how to use IDs in the constructor?!
Uh, just add them...?
Or don't have a constructor
ok, thanks! but how to reference _ctx ?
where do I get _ctx from?
It's your database context
Inject it
could you show me some code?
nice. thank you!!! 🙂
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.