"Ado.Net Entity Data Model" template with VS2010, EF6 and SQLite EF6 provider? - .net-4.0

As I got a pitch for future project specifying XP compatibility I'm trying to test combination of VS 2010 (WinXP SP3), .Net 4.0.3 (later WPF for UI), Entity Framework 6 (as I found out it should be compatible with .Net 4) and SQLite (System.Data.SQLite / .EF6).
I installed "EntityFramework" and "System.Data.SQLite EF6" packages from NuGet.
("System.Data.SQLite EF6" in turn installed System.Data.SQLite, System.Data.SQLite.EF6 and SQLite.Interop.dll)
Now trying to use "Ado.Net Entity Data Model" template, which I guessed from older tutorials would be next step I get to new connection dialog and no SQLite provider is listed there to select.
I checked my App.config and SQLite data providers are listed there. (If correctly I can't tell)
Looking like this:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework"
type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
requirePermission="false" />
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0.3,Profile=Client" />
</startup>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="v11.0" />
</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" />
</providers>
</entityFramework>
<system.data>
<DbProviderFactories>
<remove invariant="System.Data.SQLite" />
<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" />
<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>
</configuration>
The app (empty console app) compiles without errors and runs (doing of course nothing).
I am pretty green with EF + SQLite so can you please advice ?
Am I completely on a wrong track with something ?

So after another several hours of desperate googling I found a hint in an old tutorial about Visual Studio Design Time Component(s).
Apparently I was missing the Design Time Components and also System.Data.SQLite libs installed in GAC, without which VS2010 wizards don't 'see' the SQLite provider.
So despite reading in numerous official places that Setup install package is not a recommended method of getting SQLite libs into the project, it is actually the only way of making VS (2010, 12, ?13?) tools work with it.
Istalled one of "setup packages" from http://system.data.sqlite.org/index.html/doc/trunk/www/downloads.wiki . In my case "Setups for 32-bit Windows (.NET Framework 4.0)".
The Template now offers SQLite as data provider.

Related

how to deploy npgsql on Raspberry pi 2 (Mono 4 + ARM proc)?

I use Visual studio 2013 (Windows) to build a small .NET 4.5 application using Npgsql and Entity Framework 6.
On windows it just works fine.
But on Raspbian, the app crash saying it cannot find npgsql provider.
Unhandled Exception:
System.Configuration.ConfigurationErrorsException: Failed to find or load the registered .Net Framework Data Provider 'Npgsql'.
at System.Data.Common.DbProviderFactories.GetFactory (System.String providerInvariantName) [0x00000] in <filename unknown>:0
[...]
On my raspberry pi 2.
I have manually installed Mono v4.0.2
I have copied my app including:
npgsql.dll v2.2.5.0
npgsql.entityframework same version
mono.security v4.0.2
and my app.config contains :
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<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="Npgsql" type="Npgsql.NpgsqlServices, Npgsql.EntityFramework" />
</providers>
</entityFramework>
<connectionStrings>
<add name="minitestEntities" connectionString="metadata=res://*/Model2.csdl|res://*/Model2.ssdl|res://*/Model2.msl;provider=Npgsql;provider connection string="PORT=5432;TIMEOUT=15;POOLING=True;MINPOOLSIZE=1;MAXPOOLSIZE=20;COMMANDTIMEOUT=20;COMPATIBLE=2.2.5.0;DATABASE=minitest;HOST=10.0.0.1;INTEGRATED SECURITY=True;PASSWORD=azerty;USER ID=theuser"" providerName="System.Data.EntityClient" />
</connectionStrings>
</configuration>
So i'm wondering if npgsql librairies are correctly loaded, or a if a reference is missing.
I found no docs on how to use npgsql on recent mono + ARM environment.
Any info about this would be really appreciated.
ok i found the solution in an other discution. In the meanwhile i forgot to note its URL so here the answer :
We have to add manually the provider description into app.config :
<system.data>
<DbProviderFactories>
<add name="Npgsql Data Provider"
invariant="Npgsql"
support="FF"
description=".Net Framework Data Provider for Postgresql Server"
type="Npgsql.NpgsqlFactory, Npgsql, Version=2.2.5.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7" />
</DbProviderFactories>
</system.data>
The version and PuclicKeyToken MUST match with npgsql.dll.
To get the public key token, you can run that code :
typeof(Npgsql.NpgsqlFactory).AssemblyQualifiedName
Now i have no idea why this step is not necessary into windows, but a have to do into linux...

WCF Project - EntityFramework 5.0.0 ' 'Could not load file or assembly 'EntityFramework...' Error

I have a WCF Service application that uses EntityFramework 5.0.0 and when I called the method that uses the EDMX framework I get the below given message.
The server encountered an error processing the request. The exception message is 'Could not load file or assembly 'EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The system cannot find the file specified.'. See server logs for more details.
Here are my config snippets:
App.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="v11.0" />
</parameters>
</defaultConnectionFactory>
</entityFramework>
</configuration>
Packages.config
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="EntityFramework" version="5.0.0" targetFramework="net45" />
</packages>
Web.config
<assemblyBinding>
<dependentAssembly>
<assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
</dependentAssembly>
</assemblyBinding>
Am I missing anything? What do I have to check?
Help Please!!
.NET 4.5 is required. However, EF5 will run on .NET 4
So you have to check that IIS Application pool is configured to support .Net FrameWork 4.0.
For example: Sharepoint 2010 requires ASP.Net 3.5, so it does not support EF5.
Summary with the help of #Ruslan-Dayanov:
Configure and Use the Fusion Log Viewer to see where the service looks for the dll. Make sure the dll is available in that location.
References
How to configure Fusion Log: Hanselman's Guide
MSDN article on Fusion Log Viewer: Click Here

Configuration of System.Runtime.Caching vs Enterprise Library 5 caching block

As part of plans to migrate an existing website from .NET 4 to .NET 4.5.1 we have learned that we will need to move from using Enterprise Library 5 to version 6.
We're using the caching block in version 5, but this has been removed from version 6, so we plan (as recommended) to refactor our code to use System.Runtime.Caching instead.
We would like to ensure that the settings (in Web.config) we will for System.Runtime.Caching will give us the same (or similar...) behaviour as those we currently use for the Enterprise Library 5 caching block.
The Enterprise Library 5 caching block settings we are currently using are:
<configSections>
<section name="cachingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Caching.Configuration.CacheManagerSettings, Microsoft.Practices.EnterpriseLibrary.Caching, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
</configSections>
<cachingConfiguration defaultCacheManager="Cache Manager">
<cacheManagers>
<add name="Cache Manager"
type="Microsoft.Practices.EnterpriseLibrary.Caching.CacheManager, Microsoft.Practices.EnterpriseLibrary.Caching, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
expirationPollFrequencyInSeconds="60"
maximumElementsInCacheBeforeScavenging="1000"
numberToRemoveWhenScavenging="10"
backingStoreName="NullBackingStore" />
</cacheManagers>
<backingStores>
<add type="Microsoft.Practices.EnterpriseLibrary.Caching.BackingStoreImplementations.NullBackingStore, Microsoft.Practices.EnterpriseLibrary.Caching, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
name="NullBackingStore" />
</backingStores>
</cachingConfiguration>
The System.Runtime.Caching settings we are planning to use are:
<system.runtime.caching>
<memoryCache>
<namedCaches>
<add name="default"
cacheMemoryLimitMegabytes="10"
physicalMemoryLimitPercentage="0"
pollingInterval="00:01:00" />
</namedCaches>
</memoryCache>
</system.runtime.caching>
Are we on the right track here?
Note that we do not have comprehensive load testing facilities for our website, so are not able to satisfactorily test our use of caching before we release the website.

Having trouble with LinqPad Adding a Connection to Entity Framework

I am new to Entity Framework and Linq to Entities and I want to try LinqPad but I can't figure out how to make a connection to the edmx model I have created.
I have an MVC project and I added an ADO.Net Entity Data Model against a SQL Sever database ( a Development server, not one on my local machine) Did a Build.Right click in my designer surface and Add Code Generation Item. That has given me two .tt folders, one for my dbContext class, one with all my classes.
Open LinqPad click on Add Connection. Point to the .dll file in my solutions bin folder, then in the Full Type Name of dbContext I choose the entity I created. Now is whee I am having trouble making this work. I point to the solution web.config file and when I click the Test button I get an error saying "Could not load file or assembly 'Entity Framework version=..." & "The system cannot find the file specified. (C:\users..\web.config line 9" Any ideas?
I took configSections away from config file and connection works.
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.3.1.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</configSections>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlCeConnectionFactory, EntityFramework">
<parameters>
<parameter value="System.Data.SqlServerCe.4.0" />
</parameters>
</defaultConnectionFactory>
</entityFramework>
I've had this exact problem with LinqPad 4.42.01. My project is a web project using an EF5 data assembly. I ended up creating a linqPad.config file (below) in the web projectMy and it works great.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<connectionStrings>
<remove name="MySqlServer"/>
<add name="MySqlServer" connectionString="Data Source=mydb;Initial Catalog=mycat;User ID=iamuser;Password=soopersekret;Trusted_Connection=False" providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>

LinqPad - EntityFramework 4.3.1 - MissingMethodException - Sql Compact

I have my POCO model is seperate dll than my asp.net mvc 3 website.
I created new connection in LinqPad Beta: v4.41.01 selected option for Poco, provided path to custom dll, Chose DbContext, Chose via parameterless constructor.
This did not work, as I am using SqlServer Compact.
Then I created dummy.config file as follows:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.3.1.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</configSections>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlCeConnectionFactory, EntityFramework">
<parameters>
<parameter value="System.Data.SqlServerCe.4.0" />
</parameters>
</defaultConnectionFactory>
</entityFramework>
<connectionStrings>
<add name="ModelContext"
connectionString="data source=database.sdf"
providerName="system.data.sqlserverce.4.0" />
</connectionStrings>
</configuration>
With this, Test on connection is shown successful. Even, tree on left is also populated. But when I run any query, it throws exception as follows:
Method not found: 'System.Data.Entity.DbSet`1 InventoryModelContext.get_xxx()'.
EDIT: Also, note that this seems to be compilation error!
Any solution or workaround? Am I missing something?
Thanks in advance.
I had this problem as well, it started without any apparent reason - did not change anything in my environment.
I am using EF4.2 Poco, LINQPad 4.42.01
To resolve I started running LINQPad as Administartor, it solved it. I am not sure what has changed that made it break, I have not used LINQPad for a while, so maybe it was some auto-update of LINQPad or something like that.
Update: After reinstalling, for some reason the Administartor trick was not working, a new method I found is query first without specifying a database (at the top right, it says <None>), then i get an error that what I am querying for does not exists in this context, and then I set the database to the correct context, and it works.
Still not sure what is actually causing it.