Wisej - EntityFramework - Options?

0
0

Hello,
I’m currently trying out Wisej and trying to build a simple application using EntityFramework and SQLite.
I quickly realized that there were some reference difficulties. So I tried EF version 3.1 (valid for .net 4.8) but I keep getting the problem that a file is missing on execution:
assembly system.threading.tasks.extensions.
Reloading via Nuget doesn’t do it.

I’ve tried various variations but keep failing. And that with a small test application….

Has anyone here had a similar problem or how do you solve it?
Would be very grateful for a push in the right direction.

Best regards
Manu

  • You must to post comments
0
0

Hi Manu,

SQLite is tricky to get up in dotnet 4.x and seems impossible to get Entity Framework 6 to work with it, although  SQLite is supposed to work with EF in Core, I don’t know why it’s not backported from core to .net?

Solution :  Maybe use MsLocalDb from SqlLocalDB.msi via SQL Server Express LocalDB – SQL Server as per EFDesigner2022/src/Examples at master · msawczyn/EFDesigner2022 (github.com)  or  SqlServer Express although these are both out of process and require admin rights to install support software

Problem: EF 6 does not offer code first for SQLite in .net.  EF Core supports code first and migrations for SQLite.

Refer to msallin/SQLiteCodeFirst: Creates a SQLite Database based on a EdmModel by using Entity Framework CodeFirst. (github.com)


Failing to get a working: Wisej, Sqlite Ef6 and .net48  example at Opzet/WjSqlite (github.com)

 

Web.config changes required to register provider and Factory.
  <configSections>
    <!-- For more information on Entity Framework configuration, visit ... -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
  </configSections>
  
  <entityFramework>
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
      <provider invariantName="System.Data.SQLite.EF6" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" />
      <provider invariantName="System.Data.SQLite" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" />
    </providers>
  </entityFramework>
  
  <system.data>
    <DbProviderFactories>
      <remove invariant="System.Data.SQLite.EF6" />
      <add name="SQLite Data Provider" invariant="System.Data.SQLite.EF6" description=".NET Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" />
      <add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".NET Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" />
    </DbProviderFactories>
  </system.data>

  <connectionStrings>
    <add name="sqliteCon" connectionString="Data Source=|DataDirectory|db.sqlite;" providerName="System.Data.SQLite.EF6" />
  </connectionStrings>

 

Step 1:

Install SQLite in GAC

Download the latest sqlite-netFx46-setup-bundle-x86-2015-1.0.xxx.0.exe

https://system.data.sqlite.org/downloads/1.0.118.0/sqlite-netFx46-setup-bundle-x64-2015-1.0.118.0.exe

a. Select “Full Installation”

b. Select:

– Install the assemblies into the global assembly cache

– Install VS designer components

Step 2: Sqlite provider and engine

Install-Package System.Data.SQLite

Step 3: Entityframework ORM – EF 6.4.4

Tools> NuGet Package Manager> Package Manager Console

Install-Package EntityFramework -Version 6.4.4

Step 4 :Download and install Entity Framework Visual Editor

https://marketplace.visualstudio.com/items?itemName=michaelsawczyn.EFDesigner2022

Visual EFDesigner is github tool makes light work database work Entity Framework Designer 2022: Entity Framework visual design surface  (github.com) it has lots of examples too EFDesigner2022/src/Examples at master · msawczyn/EFDesigner2022 (github.com) [ btw I am the author 😉 ]

 

 

David

 

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.