SQLite with EntityFramework - Problems with database creation
Posted: Wed 18 Mar 2015 07:20
Hello all
I am evaluating dotConnect for SQLite with EntityFramework. I did a sample project according to the official sample of this forum and it did not work so far.
My Config-File looks like this:
and my Code is quite simple:
I tried many different things and also downloaded one example I found here in the forum, but it did not work either. The database file is created, but there is no data in it.
Version information:
dotConnect:
Downloaded Professional Version 5.2 yesterday (from here: http://www.devart.com/dotconnect/sqlite/download.html)
SQLite
Nuget Package "System.Data.SQLite" version 1.0.96 (x86/x64)
EntityFramework
Nuget Package "EntityFramework" Version 6.1.3
It would be nice if anybody could help me.
Regards Daniel
I am evaluating dotConnect for SQLite with EntityFramework. I did a sample project according to the official sample of this forum and it did not work so far.
My Config-File looks like this:
Code: Select all
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<system.data>
<DbProviderFactories>
<remove invariant="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, Version=1.0.96.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139" />
<remove invariant="System.Data.SQLite.EF6" />
<!--<add name="SQLite Data Provider (Entity Framework 6)" invariant="System.Data.SQLite.EF6" description=".Net Framework Data Provider for SQLite (Entity Framework 6)" type="System.Data.SQLite.EF6.SQLiteProviderFactory, System.Data.SQLite.EF6, Version=1.0.96.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139" />-->
<remove invariant="Devart.Data.SQLite" />
<add name="Devart SQLite Provider Factory" invariant="Devart.Data.SQLite" description="Devart ProviderFactory that supports table generation with Entity Framework" type="Devart.Data.SQLite.SQLiteProviderFactory, Devart.Data.SQLite, Version=5.2.359.0, Culture=neutral, PublicKeyToken=09af7300eec23701" />
</DbProviderFactories>
</system.data>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
<!--<defaultConnectionFactory type="SqliteEval.EntityFramework.ConnectionFactory, SqliteEval">
--><!--<parameters>
<parameter value="mssqllocaldb" />
</parameters>--><!--
</defaultConnectionFactory>-->
<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" />
<provider invariantName="Devart.Data.SQLite" type="Devart.Data.SQLite.Entity.SQLiteEntityProviderServices, Devart.Data.SQLite.Entity, Version=5.2.359.6, Culture=neutral, PublicKeyToken=09af7300eec23701"></provider>
</providers>
</entityFramework>
<connectionStrings>
<clear />
<add name="DatabaseContext" connectionString="DataSource=D:\data.db;Version=3" providerName="System.Data.SQLite" />
</connectionStrings>
</configuration>
Code: Select all
static void Main(string[] args)
{
// string connectionString = @"DataSource = D:\data.db;Version=3;";
File.Delete("D://data.db");
Database.DefaultConnectionFactory = new SqLiteConnectionFactory("D://data.db", null);
Database.SetInitializer(new CreateDatabaseIfNotExists<DatabaseContext>());
using (DatabaseContext databaseContext = new DatabaseContext())
{
Console.WriteLine("ConnectionString: {0}", databaseContext.Database.Connection.ConnectionString);
databaseContext.Database.Initialize(true);
}
}
Version information:
dotConnect:
Downloaded Professional Version 5.2 yesterday (from here: http://www.devart.com/dotconnect/sqlite/download.html)
SQLite
Nuget Package "System.Data.SQLite" version 1.0.96 (x86/x64)
EntityFramework
Nuget Package "EntityFramework" Version 6.1.3
It would be nice if anybody could help me.
Regards Daniel