Тёмный

C# CRUD Operations With SQLite Database Using Entity Framework 

Tactic Devs
Подписаться 5 тыс.
Просмотров 30 тыс.
50% 1

#EntityFramework #SQLite #CRUD
Project Source Code
git.io/J0kYN

Опубликовано:

 

2 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 62   
@SL-nh6mn
@SL-nh6mn 2 года назад
Excellent tutorial, very clear and concise. While running tests, pressing the Update Button while TextBlock fields are empty (prior to any data going in them), the if statements conditions fail to prevent execution and throws an exception. Swapping the conditions e.g. (name != null ) to (!String.IsNullOrWhiteSpace(name) ) resolves this issue. Hopefully this is of use to someone.
@fredwbd95
@fredwbd95 Месяц назад
I'm super happy to have run across this in my search for C# CRUD with SQLite... not only is it a great start for the entity framework, but you also taught me a few things about WPF and binding and a few other little helpful things. Nice.
@TheHvazz
@TheHvazz 2 года назад
Excellent video! Thank you so much for this explanation and introduction. I wish you all the best :)
@broffutt
@broffutt 2 года назад
This video is absolute gold.. I'm 100% new to C# and xaml, and I'm trying to build a point of sales system for my dad's friend's business. For about a week now I've been trying to figure out how to work with sqlite and how c# and xaml relate to the database... This video has answered every single question i had and then some that i would've ended up asking later down the road... you, sir, are a god send
@sivasothytharsi1203
@sivasothytharsi1203 Год назад
sir how to do with mvvm approach and code first method could you please explain me?
@Kennerdoll
@Kennerdoll Месяц назад
32:24 private void MenuItem_Click(object sender, RoutedEventArgs e) { DatabaseUser?.Clear(); ItemList.ItemsSource = null; ItemList.ItemsSource = DatabaseUser; }
@goldfang5191
@goldfang5191 2 года назад
u saved my exam, thx man.
@Kennerdoll
@Kennerdoll Месяц назад
32:24 to clear the database: private void MenuItem_Click(object sender, RoutedEventArgs e) { using (DataContext context = new DataContext()) { var allUsers = context.Users.ToList(); context.Users.RemoveRange(allUsers); context.SaveChanges(); } }to clear the database:
@FANTICOUS32
@FANTICOUS32 3 месяца назад
Why not just write changes directly in the grid?
@AmirRobo
@AmirRobo Месяц назад
it's cool and amazing. Thanks a lot 💯
@SergioTavazzi
@SergioTavazzi Месяц назад
Hi, and thanks for all. I want to tell You that for me (Visual Studio 2022) has been impossible download the default entity.sqlite package. But choosing an older version (3.1.22), the download has been accepted and is working.
@TacticDevs
@TacticDevs Месяц назад
@@SergioTavazzi Yeah sometimes it happens that way
@Kennerdoll
@Kennerdoll Месяц назад
Bro ur Zambian right ?
@maghdammohsen
@maghdammohsen 11 месяцев назад
it was very good.
@dmitriynovikov6363
@dmitriynovikov6363 10 месяцев назад
Hi, I wanted to thank you for this video lesson and also have a question. Has anyone encountered the problem of missing e_sqlite3.dll on Win11 VS22. Since I downloaded sqlite through NuGet packages, and when the error occurred, I also downloaded it through the official site. If there are mistakes in the text, sorry, I'm from Ukraine, I do not know your language.
@TacticDevs
@TacticDevs 10 месяцев назад
If sqlite3.dll is missing It means visual studio could not download the library that’s, why it’s important to use nuget package manager in visual studio it will help you manage the DLL files of your project and remember to type in the correct name of the package because there are so many packages with similar names,
@SergioTavazzi
@SergioTavazzi Месяц назад
try to use an older version of the package, for me has worked the 3.1.22
@xbxb
@xbxb Год назад
Great Tutorial! I'm new here. How can I do the, I have admin account and then there's users account? Only admin can do the CRUD.
@rinshima
@rinshima 2 года назад
Thank you very much, I haven't watched the video yet, but it helped me in the beginning with my knowledge of data bindings, and I'm sure it will help with databases too.
@markus72wi
@markus72wi 10 месяцев назад
Amazing work , thank you for your afford. Your teaching style helps a lot to understand the topic.
@sigib911
@sigib911 Год назад
Amazing videos, do you have a full couse of WPF? I would love to take it
@jerichosantonia6412
@jerichosantonia6412 2 года назад
THANK YOU SO MUCH! YOU'RE A HUGE HELP. I hope you are doing very good now. Keep making videos like this sir. You're so great!
@fadhlanwasim
@fadhlanwasim 9 месяцев назад
I can't describe how superb this tutorial is. Thank you ❤
@hamzaelmossaoui9286
@hamzaelmossaoui9286 2 года назад
I have watched maybe 20 videos about XAML but no videos was as good as yours!! You explain everything very good! Thanks.. Keep up the good work
@davidsantos6205
@davidsantos6205 2 года назад
Hi, in the Remove command is not appearing on my project
@fooballers7883
@fooballers7883 Год назад
WoW... thank you so much for this tutorial...You are a born teacher... should have a fee paying classes. Really appreciate this lecture.
@kiaora2601
@kiaora2601 2 года назад
Thank you a lot! I've been struggling to find information about CRUD (without all this select * and etc). but your channel and the way you explain it's just priceless! thank you for your time and efforts!
@maxdesko
@maxdesko 2 года назад
Thank you so much, this tutorial is so valuable.
@davidson7838
@davidson7838 3 года назад
Hello Sir, I liked this video. can you make a WPF course or video series on WPF/MSSQL for something like a POS or for an APPOINTMENT system, where users have to login first and according the user's role he/she do tasks. Thank you very much & keep up the good work.
@TacticDevs
@TacticDevs 3 года назад
Sure I will starting working on that
@davidson7838
@davidson7838 3 года назад
@@TacticDevs Thank you so much. I would also like to include few lessons about WPF designing as well.
@davidson7838
@davidson7838 3 года назад
Can you share the source code for this demo via github?
@TacticDevs
@TacticDevs 3 года назад
@@davidson7838 Sure the link is in the video description now
@TacticDevs
@TacticDevs 3 года назад
@@davidson7838 git.io/J0kYN
@liamlluls1588
@liamlluls1588 Год назад
Thanks
@АндрейРазин-и6ш
@АндрейРазин-и6ш 2 года назад
Thank you very much!
@jesuspereiraoficial
@jesuspereiraoficial 3 года назад
Nice video. Thnaks Bro!
@DJone4one
@DJone4one Год назад
The video is good. It's just a bit silly that you didn't use the update function immediately after creating a new data set. That would have been more intuitive. That the ListView is reloaded immediately when a record is created. Ich habe den Code etwas verbessert. So ist er funktionaler. public MainWindow() { InitializeComponent(); Read(); } public void Create() { using (DataContext context = new DataContext()) { var name = NameTextBox.Text; var adresse = AdressTextBox.Text; if (Name != null && Adresse != null) { context.Users.Add(new User() { Name = name, Adresse = address }); context.SaveChanges(); } } Read(); NameTextBox.Text = ""; AdresseTextBox.Text = ""; }
@TacticDevs
@TacticDevs Год назад
That could be done However in this case I wanted to demonstrate the read function as an individual operation , that means you have to manually read
@DJone4one
@DJone4one Год назад
@@TacticDevs Ah ok. But I have now noticed something else in my case that can also lead to mistakes for others who are about to start. The Nuget package EntityFrameworkCore.Sqlite is only compatible with the new .Net standard WPF project. Not to the .Net Framework WPF. There is already an error when installing the Nuget package, when I built it. But I also didn't pay attention to whether you had previously mentioned which project template you were using. I just wanted to let you know if someone builds this and gets this error.
@TacticDevs
@TacticDevs Год назад
@@DJone4one You’re right I forgot to mention the project template
@aliamoo8564
@aliamoo8564 2 года назад
how can i create two table in one .db file?
@TacticDevs
@TacticDevs 2 года назад
You can add another DbSet property the to the Dbcontext class the DbSet Property represents a database table, the more you add more database tables you will have
@fazalrehman1931
@fazalrehman1931 3 года назад
Hello! i have issue i con't connect my SQLite database with Entity Frame work 6 can you please help me.
@TacticDevs
@TacticDevs 3 года назад
You need to make sure that the connection string is correct and make sure that the name of the DBset property in the context class is the same as the table name
@TacticDevs
@TacticDevs 3 года назад
As well as do not forget to use the Facade class that is found in entity framework infrastructure namespace use this class to ensure that the database file is created when the application starts up,have a look at 11:55
@tristy7364
@tristy7364 2 года назад
I tried using only the create method to input details into the database, but this exception wan thrown: SqliteException: Microsoft.EntityFrameworkCore.DbUpdateException: 'An error occurred while updating the entries. See the inner exception for details.' SQLite Error 19: 'NOT NULL constraint failed: Users.Id'. Any tips?
@TacticDevs
@TacticDevs 2 года назад
it seems you tried to write a null value to the id property, the other issue might be that you named the the User class ""Users"" ,Entity frame will also name the table "Users" this might cause a name conflict so you can remove the "s"
@tristy7364
@tristy7364 2 года назад
@@TacticDevs I fixed it, my Id properties in the table allowed or didn't allow nulls
@TacticDevs
@TacticDevs 2 года назад
@@tristy7364 great to hear👍🏼
@federicapecci9142
@federicapecci9142 2 года назад
Hi Tactic Devs, thank you very much for your helpful tutorial. Once I run the app and hit the create button, the db file doesn't create. What might the reason be? Cheers, Federica
@TacticDevs
@TacticDevs 2 года назад
The DB file is created during the start up process of the application, This is done by calling the ensurecreated method from the database façade class, Check the App.cs and Verify the code 11:55 Or 14:03, However if the DB file is already created it means The problem occurs when you try to create an entry in the database it’s means should verify the create method that was defined in the mainwindow class 15:43
@federicapecci9142
@federicapecci9142 2 года назад
@@TacticDevs the ensurecreated method always returns false. It seems like the database has already been created even if it's not cause when i look for it in the bin directory i can't find it. Can I check out anything else?
@TacticDevs
@TacticDevs 2 года назад
@@federicapecci9142 Is it possible if you can share with me the source code maybe using Google Drive
@federicapecci9142
@federicapecci9142 2 года назад
@@TacticDevs Unfortunately i can't
@moudhafferbouallegui
@moudhafferbouallegui 7 месяцев назад
Poor architecture. You're definitely not supposed to allow database connections from within your client.
@TacticDevs
@TacticDevs 7 месяцев назад
I understand that , however this video is about how to communicate with a database rather than focusing on project structuring or adhering to SOLID principles. thats for a separate video
@fredwbd95
@fredwbd95 Месяц назад
Why? This is SQLite, not some enterprise SQL server. I'm using SQLite for local storage, user interface and project settings, not some enterprise database with private user data. No reason to be so rigid.
Далее
WPF Login system with SQLite using C#
21:19
Просмотров 24 тыс.
ЭТО НАСТОЯЩАЯ МАГИЯ😬😬😬
00:19
Entity Framework Migrations Explained
36:53
Просмотров 31 тыс.
The Basics of Data Binding in WPF
20:53
Просмотров 43 тыс.
Learn Drizzle ORM in 13 mins (crash course)
14:00
Просмотров 28 тыс.
Being Competent With Coding Is More Fun
11:13
Просмотров 86 тыс.
Get started with ENTITY FRAMEWORK in C#!
15:57
Просмотров 19 тыс.
What is Entity Framework Intro [1 of 3]
4:55
Просмотров 9 тыс.