Can I use EF4 in VS 2012? - entity-framework

I wanted to follow up on a post from last year ("EF5 , Widows Forms , Dragging a chield entity from project datasource into a GridView creates only 2 columns").
I believe the problem described with EF5 is still true and the solution found (use EF4) continues to be the only reasonable answer.
Before I upgrade to VS2012, I wanted to check whether anyone knows if there is any problem using EF4 in VS 2012.
Anyone with experience on this?

VS2012 requires .NET Framework 4.5 which is an in-place update. This means that once you install the .NET Framework 4.5 it will be always used when running .NET Framework 4 or .NET Framework 4.5 apps. This also means that you will be running EF5 even if you target .NET Framework 4 in VS (targeting is only a design time thing which prevents from using APIs that were not available in the targeted .NET Framework version while at runtime the app will use the version installed on the box).
With regards to the problem you are reporting - take a look at this bug report on the EF codeplex site as it apparently contains a solution to the problem

Related

Can Entity Framework 6 be used in a .NET Standard project?

And if not, will it be? If so, when?
I haven't been able to find any clear official information on this, and the limited information I was able to find on Stack Overflow is a year or two old.
I was able to find official information saying EF 6.3 will be able to be used in a .NET Core project, but I couldn't find a release date for it, nor am I sure what the implications for use in a .NET Standard project are.
EF 6 supports .NET Standard 2.1, which is currently supported by .NET Core 3.0 or later - no .NET Framework version. EF 6 also supports .NET 4.0 and 4.5 or later.
https://github.com/aspnet/EntityFramework6/blob/release/6.4/src/EntityFramework/EntityFramework.csproj#L6
Some clarification, since EntityFramework 6.3.0 .NET Standard 2.1 has been supported. However there is no .NET Framework version that supports .NET Standard 2.1. Comment from Microsoft:
NET Framework won't support .NET Standard 2.1 or later versions. For
more details, see the announcement of .NET Standard 2.1.
This means that a majority of all applications using EntityFramework 6.X won't be able to use the .NET Standard 2.1 project anyway.
https://learn.microsoft.com/en-us/dotnet/standard/net-standard
https://www.nuget.org/packages/EntityFramework/#

Set .NET Framework version for ScriptComponentProject

Is it possible to set the .NET Framework version for a ScriptComponentProject?
Currently it defaults to .NET 4, but I want it to be .NET 4.6.1
I've looked on the documentation page for ScriptComponentProject (https://www.varigence.com/Documentation/Samples/Biml/Script+Component+Project), but without any luck.
Ah, I found the answer! You need to set the Target Framework Version in your script project:
https://www.varigence.com/Documentation/Language/Element/AstComponentScriptProjectNode
And I think the available values are these:
Unspecified
Unspecified .NET Framework Version
NetFX20
.NET Framework 2.0
NetFX30
.NET Framework 3.0
NetFX35
.NET Framework 3.5
NetFX40
.NET Framework 4.0
NetFX45
.NET Framework 4.5
NetFX451
.NET Framework 4.5.1
NetFX452
.NET Framework 4.5.2
NetFX46
.NET Framework 4.6
NetFX461
.NET Framework 4.6.1
Which can be found here: https://www.varigence.com/Documentation/Api/Enum/ScriptProjectTargetFrameworkVersion
If you are using BIMLExpress 5.0.6xxx, you have probably faced the same issue.
I opened the generated .dtsx package and found that the TargetFrameworkVersion node placed inside of a separate PropertyGroup node. After I had moved it out to the first PropertyGroup of the same arrayElement node, then reopened my package in Visual Studio again, issue was gone! So you can write a script to move TargetFrameworkVersion node into the proper place for now.
Varigence support team told me that a public preview release is coming late next week which will include a fix for that (+also VS2017 support!).

Upgrading from the June CTP EF 4.2

We're currently developing an application that is using EF Code first (EF June 2011 CTP).
My first question is: Is it worth trying to upgrade to use a later version of EF?
Secondly, if so, does anyone know the steps involved to upgrade - when I try to install the NuGet package for EF 5.0 - beta 2, I end up with issues as the target framework is still 4.2.
Many thanks,
James.
The CTP is long time dead with no other version coming because all that stuff is currently part of .NET 4.5 beta and EF 5.0 beta. You must upgrade to those two and the upgrade will consist of re-targeting application back to .NET 4.0 / .NET 4.5, removing all dependencies to your current EF version and re-adding those dependencies for .NET 4.5 / EF 5.0.
Some time ago I wrote a blog post on this: http://blog.3d-logic.com/2012/04/11/entity-framework-zombie-a-k-a-microsoft-entity-framework-june-2011-ctp/. There is a number of issues with CTP 4.2 because of technical challenges related to shipping a .NET Framework library out of the .NET Framework (like 4.2 target). Move to .NET Framework 4.5 that contains the same feature set as EF 4.2 + bug fixes and has a go-live license. Use EF 5.0 on top of it and you will be in a better world.
Thanks for all the responses.
My main issue is that we rely heavily on ENUMs in our implementation of 4.2 code first. I attempted to migrate the project to 4.5 but ENUMs are not supported, and there is also an issue with table per hierarchy (which is easy to fix). The next move will be to upgrade to VS11 and use 5.0 - but this is a big undertaking.
#jwsadler:
Enums are supported by core EF libraries released as part of .net Framework 4.5 (e.g. System.Data.Entity.dll). To make enums work with CodeFirst/DbContext you do need EF 5.0.0 package from NuGet (use Install-Package EntityFramework -pre (-pre is important)). You need VS 11 for this since Visual Studio 2010 cannot be used to create applications that target .NET Framework 4.5. Note that when installing the nuget package on Visual Studio 11 the target version of the .NET Framework set for the project is taken into account. If you target .NET Framework 4 you will not be able to use EF5 features like enums or spatial.

EF 4.3.1 with VS 2011

I need to know if it is possible to start using the latest version of EF (4.3.1) with VS 2011 without having to install these CTP components as stated here.
I had these components installed but I removed them and since then I can't add a new edmx file to .net 4 targeted project; it complains about missing reference to System.Data.Entity.
Do I need to re install VS 2011?
After I removed and reinstalled Visual Studio, I still couldn't get red of the error, so I used process monitor to log what Visual Studio is doing with System.Data.Entity as a path filter, turned out that Visual Studio was reading from
C:\Windows\Microsoft.NET\assembly\GAC_MSIL\policy.4.0.system.data.entity v4.0_0.0.0.0__b77a5c561934e089\policy.4.0.system.data.entity.config
which had binding to the
System.Data.Entity.dll v 4.2.0.0
once I cleared the file VS was worked like charm.
The CTP uninstall left this out.
Yeah should work with no issues using .net 4, however theres a list of known issues when using .net 4.5. You dont need to re-install vs to get version 4.3.1 of entity framework, simply install it from the nuget package gallery and if you are using .net 4 it all seems to just work.
Issues listed when installing EF4.3.1 on .net 4.5 include those listed below.
Known Issues with Entity Framework 4.x and .NET Framework 4.5
Entity Framework 4.1 thru 4.3 included additional data annotations in the
System.ComponentModel.DataAnnotations namespace in the EntityFramework assembly.
In .NET 4.5 these annotations were moved to be part of the .NET Framework in the
System.ComponentModel.DataAnnotations.Schema namespace of the
System.ComponentModel.DataAnnotations.dll assembly. If you are using EF 4.x and targeting
.NET 4.5 this results in two data annotations with the same name in different assemblies.
Because the annotations in the .NET Framework are in a different namespace we were not
able to use type forwarding to avoid this conflict.
It is possible to use EF 4.x on .NET 4.5 but we recommend using the latest pre-release
version of EF 5. If you are not using the affected data annotations there is no impact
on your code. If you are using the data annotations in a C# project you can use the extern
modifier to ensure your code uses the annotations from EntityFramework.dll
(http://msdn.microsoft.com/en-us/library/e59b22c5(v=VS.80).aspx). If you use the new
annotations from the System.ComponentModel.DataAnnotations.dll assembly in .NET 4.5
they will not be processed by Code First.
The affected annotations are:
Column
ComplexType
DatabaseGenerated
DatabaseGeneratedOption
ForeignKey
InverseProperty
MaxLength
MinLength
NotMapped
Table

Convert MVC2 .NET 4 application to run on .NET 3.5

This might seem like an odd request, but is there any simple way to downgrade my ASP.NET MVC2 application running on .NET 4 (developed in VS2010) to run on .NET 3.5? I'm asking because the server I will be using to host the application on is within my university and only has.NET 3.5 installed.
Many thanks
The ASP.NET MVC 2 is built against .Net 3.5 so there is no downgrade needed there. The only problem you might have is your own code - if you are using some .Net 4.0 specific stuff you will have to change it. For starters change your projects target framework (in project properties) to 3.5 and check if it still builds.