We have some code that utilizes the EntityStoreSchemaGenerator to auto-generate an entity model from a database.The code is based on the EdmGen2 code from here:
http://archive.msdn.microsoft.com/EdmGen2/Release/ProjectReleases.aspx?ReleaseId=4216
This has worked well in previous versions of the EntityFramework, However; in EF 6.0.1 the code no longer compiles.
It seems that the support for generating models on the fly has been removed in the latest EF version. Can anyone confirm this?
Is there an alternative solution to generate the model classes on the fly, from code, available in EF 6.0?
Related
I need to upgrade my existing .net framework project to .net core 2.0.
I have noticed that .NET Core 2.0 doesn't have support for EDMX (Entity Framework). Do I need to convert EDMX to Code First approach and then upgrade to .NET Core?
What is the easiest and quickest way to do that?
Will EF 5.x DbContext Fluent Generator for C# help to convert EDMX to Code First?
You do not convert EDMX to Code First. What you need to do is reversed engineering by Scaffold-DbContext command, based on the existing database. You can completely remove the EDMX, current context and model classes and let EF Core scaffold new classes. From that point on, you work in Code First mode (make changes to model classes and create migrations, etc). Please see this link for instruction how to do it:
https://www.entityframeworktutorial.net/efcore/create-model-for-existing-database-in-ef-core.aspx
I have a Data Access Layer solution built in Visual Studio 2010. It uses Entity Data Model (.edmx files) to create object models of the data.
It is built with .Net 3.5 framework so I assume this is also version 3.5 of Entity Framework?
We use a number of TVFs to return datasets and unfortunately EF 3.5 does not provide access to TVFs. So we have has to build tsql views that call those TVFs.
Is it possible to upgrade this solution to EF 6 and use TVFs? What are the steps involved?
Microsoft has release a guide to do. You find it here:
https://msdn.microsoft.com/en-us/data/upgradeef6.aspx
It involves getting the latest assemblies and do some modifications in order to run. It seems upgrading from an older version is a little harder than from a new version.
I am trying to upgrade a big data project from EF 5 to EF 6. But when I run the code generation in EF6 tool the references to the related tables are no longer there.
So the following line of code no longer works.
dbTradeAllocation.ChargeTypeReference.EntityKey = new EntityKey("ICEEntities.SystemData", "ID", TradeAllocation.ChargeType);
Does anyone know if EntityKeys are still supported in EF6 ?
Thanks Paul
EntityKey is supported in EF6. However you cannot run EF5 code generation in EF6 - it won't work since there were changes in namespaces. I touched a little bit on this in my blog post about changes to EF Tooling in VS2013 - you can find the blog post here. If you want to use EntityObject/ObjectContext entities in EF6 you need to use EntityObject generator for EF6 which you can get from VS Gallery (note it requires .NET Framework 4.5 on the dev box).
I have a table with a SQL Geometry column. Now I'm trying to work with EF but the mapper doesn't want to include it (it should be supported by now, as I saw here). Also, I can't find the Spatial Types in the EF Designer as I saw here.
I have done so far:
PM> Install-Package EntityFramework –IncludePrerelease
'EntityFramework 5.0.0-beta2' already installed.
MyProject already has a reference to 'EntityFramework 5.0.0-beta2'.
and after this, the version of the referenced EnitiyFramework.dll is:
4.4.0.0
Sadly, if you are targeting .net 4, it would not work: Some features are only available when writing an application that targets .NET 4.5. This includes enum support, spatial data types, table-valued functions and the performance improvements. If you are targeting .NET 4.0 you still get all the bug fixes and other minor improvements.
source: http://blogs.msdn.com/b/adonet/archive/2012/03/22/ef5-beta-2-available-on-nuget.aspx
Also, if you are targeting 4.5, look here: How to get enums working in mvc4 with Entity Framework 5 Beta 2?
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.