Ok, so I installed EF 4.2 from NuGet. Just did Install-Package EntityFramework. That's all I've done.
Now what?
How do I know I'm using the new Framework and not the old one.
I have an existing project previously with EF 4.0. I'm also using precompiled views and custom text templates. Everything looks exactly the same after I did the update.
There will be no change in existing project. EFv4.2 contains code first mapping approach and DbContext API - neither of those affects existing EFv4.0 projection. It also contains few minor helpers like strongly typed Include but you must use them in your code. That is not something that will magically change existing code.
Related
I want to define a Timestamp in my EF Core Project with SQLite and wanted to use this function:
Click
I know that this function seems to be in the classic EF and maybe it is not available anymore but 3 days ago I found the right package and the extension method that I was searching. Unfortunatelly I had another problem with the code and reverted everything and now I do not find the right package anymore. It was during a hackathon during the last hours, so i really do not remember how I got it to work :/
Does anybody know which nuget package has this method? The only thing that I am referencing is Microsoft.EntityFrameworkCore.Sqlite. I allready tried the .Core and the classic EF dependencies and some random third party sqlite/ef packages, but I still can not compile this extension method :(
As you can see from the link, this method applies to EF Core versions 1.0 and 1.1.
Starting from v2.0, most of the provider specific ForAbcXyz methods have been replaced with the generic Xyz methods.
So the method you are looking for is HasDefaultValueSql. If you support multiple databases, use it inside a block enclosed with
if (Database.IsSqlite())
{
// ...
}
I've just converted my app to Swift 3, and as part of this I have updated the well known "Charts" framework. All of my converted code is fine and building/testing well, so I have no concerns about that.
I have embedded the binary to use the framework after unlinking the old one, cleaned the project, built the project before trying to use any framework code, and cleared derived data.
However I still get a "ChartViewDelegate" is not available, cannot
find swift declaration for this protocol.
This is odd to me, as the Charts module imports fine, and autocomplete recognised all member classes of the framework. Also, it doesn't seem to be an issue with the framework, as when implementing the framework on a "fresh" project, it works perfectly as expected.
I'm at a loss of what to try next, apart from rewriting an entire app into a fresh project where I know the framework works. The framework is an integral part of the app. Thanks!
EDIT: I have already tried cleaning/clearing derived data.
I've been having this problem recently with any frameworks I added to my project manually. I fixed this by totally removing the offending frameworks and then installing via cocoa pods.
I just started using EF 6 and I noticed that the first execution takes more time because it needs to be compiled, so I researched and found that you can pre-generate the view.
I used EF Power Tool to generate the view: http://visualstudiogallery.msdn.microsoft.com/72a60b14-1581-4b9b-89f2-846072eff19d/
It's a dll, and I'm building using the option Embed in Output Assembly.
The problem is that even though I have the view.cs when I execute the first query I have the same delay, so it seems that my library is not using the pre-generated view.
What could be wrong? I'm passing the connection to the entity using an EntityConnectionStringBuilder returning a EntityConnection object.
Also I tried changing the view.cs to Embedded Resource, since with Compile I did not have any changes, in both ways I still have the first time delay.
I'm sure I'm missing something, but not sure what.
Thanks in advance,
Lucas.
EF5 views will not work with EF6 (in addition to that there are some issues with EF6 Beta 1 and EF6 RC1 which prevent using views with EF6 - these issues should be fixed for EF6 RTM). I created a T4 template for generating views for EF6 - you can find more details here - again due to the problems above the views generated by the template will not work for EF6 RC1. If you absolutely think you need it you can try the version from my github - it was updated to work with EF6 RTM and also works with nightly builds.
Anyways, I am pretty sure that this is actually not view generation that are causing the issues (actually the performance of view generation in EF6 has been greatly improved). We recently found a few performance issues (see 1674 and 1662) that are affecting start up time and we are looking at these.
EDIT
The version of the template that works with EF6 RTM (6.0.0.0, 6.0.1.0) has been published to the VS Gallery
I've installed EFv4.2 via Nuget but I still don't see "DbContext generator" T4 template in EDMX model, only "Entity object generator" and "Self-tracking generator" are available. It seems that there is nothing changed.
Am I missing something ? Do I need to install EFv4.1 first ?
There are no new features. Only bug fixes.
EF 4.2 = Bug Fixes + Semantic Versioning
When we released ‘EF 4.1
Update 1’ we introduced a bug that affects third party EF providers
using a generic class for their provider factory implementation,
things such as WrappingProviderFactory. We missed this
during our testing and it was reported by some of our provider writers
after we had shipped. If you hit this bug you will get a
FileLoadException stating “The given assembly name or codebase was
invalid”. This bug is blocking some third party providers from working
with ‘EF 4.1 Update 1’ and the only workaround for folks using an
affected provider is to ask them to remain on EF 4.1. Third party
provider writers then identified some areas in EF where it was hard to
get EF to work with their providers, so we decided to address these
issues in the EF 4.2 release. These provider related changes will be
the only changes between ‘EF 4.1 Update 1’ and ‘EF 4.2’.
Obviously a single bug fix wouldn’t normally warrant bumping the minor
version, but we also wanted to take the opportunity to get onto the
semantic versioning path rather than calling the release ‘EF 4.1
Update 2’.
Extracted from ADO.NET Team Blog
Edit
The templates for using the DbContext API with Model First and
Database First are now available under the “Online Templates” tab when
“Right-Click –> Add Code Generation Item…” is selected on the EF
Designer.
Ok, I'm about to smash my keyboard with a hammer over this. I decided to play with EF this weekend and I started a project in 4.0. I find out 4.1 is out so I download and install the package.
Imagine my surprise when I go to use the Load() method in the dbExtensions and it can't find it. So I add a reference to the EntityFramework binary that the installer created, remove the System.Data.Entity reference from the project, rebuild, and it says
"The type
'System.Data.Objects.ObjectContext' is
defined in an assembly that is not
referenced. You must add a reference
to assembly 'System.Data.Entity,
Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089'."
I tried to regenerate my model, I tried removing things, I tried directly referencing the 4.1 via usings. Nothing works.
I'm obviously missing something basic. How in the heck do I tell visual studio to use the 4.1 framework??!!
I managed to find the missing .Load() function by adding the following:
using System.Data.Entity;
Entity Framework 4.1 is not separate version. It still needs Entity Framework 4.0 and its assembly so yu can't remove System.Data.Entity.dll from your references. Also EFv4.1 is mainly about new DbContext API so unless you are going to swith from Entity objects to POCOs and DbContext you will not get any advantage by referencing EntityFramework.dll (except strongly typed Include on IQueryable).
Add a Reference to System.Data.Entity.dll from either:
GAC (.Net tab in add reference dialog)
or
C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Data.Entity.dll
I got the same issue, and still don't know the root cause.
Finally I use some alternative solution:
var query = from d ...
query.Load();
or
(DbSet)context.myentity).Load();
Please try.
Ladislav's post is accurate. To add a little more detail, this ADO.Net team blog post explains how to correctly replace the code generation in an EF 4.0 project with EF 4.1.
However, I have a similar issue after upgrading to 4.1 and using DbContext (including some other features) I don't have a .Load() method either. I think you were in the same place I am before you started (unnecessarily) messing with references.
Check out the link above, let me know if it helps, and if you find a solution for the missing .Load() function be sure and let us know.