Search code examples
vb.netwinformsentity-frameworkentity-framework-6

How to use Entity Framework 6 in Windows Forms-App(.Net Framework) with vb.net?


It's pretty hard to find any documentation about this. I know that vb.net is pretty old, but I need to use it in this case. I want to implement Entity Framework in an existing Windows Forms-App(.Net Framework) (vb.net). I can't really find good tutorials that deal with vb.net.

What I already tried is following this tutorial (https://learn.microsoft.com/de-de/ef/ef6/fundamentals/databinding/winforms) to create the entity Framework classes in C#. I thought I could just access them from vb code. Sadly the c# classes aren't appearing in my data source wizard. Visual Basic classes do appear there.

I am working on a pretty old .NET Framework (4.5.2), but I also tried it in a newer version and it didn't work. Are there any vb.net experts out here that can give me some tips?


Solution

  • I haven't used EF6 + .NET Framework in years, but here are my notes from that time:

    1. Create Class Library (.NET Framework) Project
    2. Use NuGet to add Entity Framework 6.0 package
    3. Add new EDMX
    4. Add > New Item > ADO.NET Entity Data Model > EF Designer from data
    5. Do not pluralize/singularize table names
    6. To add tables: Right-click EDMX > Update Model from Database
    7. Compile project
    8. Add reference to this project from other projects that will use this entity model