C# with CSharpFritz - Ep 12: Get Started with Entity Framework Core
Vložit
- čas přidán 27. 07. 2024
- In this episode, Fritz begins accessing data using Entity Framework Core. We learn about create, read, update, and delete interactions with relational databases as well as interacting with one-to-many and many-to-many relationships in our database.
Questions:
00:21:57 What extensions are you using in Visual Studio Code for C#?
00:41:54 When would you go for a code-first vs database-first approach?
00:46:01 How do you sync the database schema to your classes if there is a change in the database?
00:47:45 Database First approach with EntityFramework Core just generates the classes?
01:06:12 What is AsNoTracking ?
01:12:07 Can you implement IPropertyChanged on the class Entity Framework returns?
01:36:06 What is the difference between DbSet and IEnumerable?
01:52:03 What are your thoughts on using the repository pattern in conjunction with EF Core?
Background Music is Harris Heller's Streambeats - Lo-Fi playlist, available royalty free at open.spotify.com/playlist/76D...
Source code and interactive content from the stream are available at: github.com/csharpfritz/csharp...
Watch live Mondays at 1300 UTC / 9a ET / 6a PT at: / visualstudio - Věda a technologie
So good to hear you don't have to create the join table model for many-to-many relationships anymore.
I am already looking forward to next week's session!
Thanks 🙏
am getting this error when i start the app without debugging
(SQLite Error 1: 'no such table: Student')
and i have updated the database, but it only works on the power shell in visual studio.
When Im trying to use GetPosts(db), AddPost(db) etc. I get unhandled exception (Microsoft.Data.Sqlite.SqliteException: „SQLite Error 1: 'no such table: Posts'.”) Even though I did everything step by step like in the video and when I use DB Browser I can see the Posts table
Could someone help me with that?
Make sure you run `dotnet ef database update` to update your schema in your database.
@@csharpfritz I arleady tried this one
No migrations were applied. The database is already up to date.
Theres more info about this error
Microsoft.Data.Sqlite.SqliteException: „SQLite Error 1: 'no such table: Posts'.”
SampleEntityFramework.Program.GetPosts(SampleEntityFramework.AppDbContext) in Program.cs
SampleEntityFramework.Program.Main(string[]) in Program.cs
It shows up at if (!posts.Any()) in GetPosts(db)
Sorry if I bother you I just want to solve this problem
09:00
The background music is extremely distracting - we are here to learn not to listen to music