Upgrade EF 4 EDMX to EF 6




My application is using a database first EDMX in EF 4. I would like to upgrade everything to EF 6. After getting EF 6 with NuGet I had to make a lot of changes to my classes that are using my EF model, because namespaces have been changed in EF 6. Then I realized, that the code generated by my EDMX does also use the wrong namespaces etc. I'm not using a custom T4 so far.


How would I upgrade my existing EDMX to EF 6.


Thank you.
1. You delete your old .tt files
2. You open your edmx file in designer mode (so you can see your model)
3. Right click on a free space
4. Select Add Code Generation Item
5. In the dialog select "EF 6.x DbContext Code Generation Item" (something like this)
6. Save your edmx and all classes will be generated for you, with the new namespaces and so on
The documentation for [`ConfigurationManager.RefreshSection`](https://docs.microsoft.com/en-us/dotnet/api/system.configuration.configurationmanager.refreshsection?f1url=https%3A%2F%2Fmsdn.microsoft.com%2Fquery%2Fdev15.query%3FappId%3DDev15IDEF1%26l%3DEN-US%26k%3Dk(System.Configuration.ConfigurationManager.RefreshSection);k(TargetFrameworkMoniker-.NETFramework,Version%3Dv4.6.2);k(DevLang-csharp)%26rd%3Dtrue&view=netframework-4.7.2) method does say (emphasis is mine):



> 
> Refreshes the named section **so the next time that it is retrieved** it will be re-read from disk.
> 
> 
> 


The problem is that EF6 caches the [`ConfigurationManager.ConnectionStrings`](https://docs.microsoft.com/en-us/dotnet/api/system.configuration.configurationmanager.connectionstrings?view=netframework-4.7.2) in an internal class static property, so it never gets refreshed.


Unfortunately there is no "official" way to refresh it. Following is a brute force hack using reflection, so use it on your own risk:



```
static readonly Type EF6AppConfigType = typeof(DbContext).Assembly.GetType("System.Data.Entity.Internal.AppConfig");

static readonly PropertyInfo EF6DefaultAppConfig = EF6AppConfigType.GetProperty("DefaultInstance", BindingFlags.Public | BindingFlags.Static);

static readonly FieldInfo EF6ConnectionStrings = EF6AppConfigType.GetField("_connectionStrings", BindingFlags.NonPublic | BindingFlags.Instance);

static void RefreshEF6ConnectionStrings()
{
    EF6ConnectionStrings.SetValue(
        EF6DefaultAppConfig.GetValue(null),
        ConfigurationManager.ConnectionStrings
    );
}

```

Just call it after saving the changes:



```
config.Save();
RefreshEF6ConnectionStrings();

``` RIA Services [is now OpenSource](http://jeffhandley.com/archive/2013/07/03/ria-services-is-getting-open-sourced.aspx) with the name "Open RIA Services" (see [on CodePlex](https://openriaservices.codeplex.com/)).


Colin Blair, the project leader, has just announced the first version with EF6 support :
<http://www.openriaservices.net/blog/post/The-Open-RIA-Services-Blog/1016/4-3-Alpha-NuGet-Packages-Released/>


You can install the Nuget package : [RIA Services for Entity Framework 6+](https://www.nuget.org/packages/RIAServicesContrib.EntityFramework).


~~If you want to install the Nuget package [RIA Services for Entity Framework 6+](https://www.nuget.org/packages/RIAServicesContrib.EntityFramework), be sure to select the "include prerelease" item in the top combo Box.~~ There is no DDEX provider package for VS 2017 (yet). <https://system.data.sqlite.org/index.html/tktview?name=8292431f51> 


Basically you need to wait for: sqlite-netFx46-setup-bundle-x86-2017-1.0.1xx.0.exe 


"Official" update:



> 
> The current estimate is that support for Visual Studio 2017 will
>  be included in the 1.0.106.0 release, which should be released at
>  some point in the mid-June timeframe.
> 
> 
> mistachkin added on 2017-05-28 20:41:40: At this point, it seems unlikely that I'll be able to add VS 2017 support for the design-time components (e.g. table designer, entity wizard, etc).
> 
> 
> 


**UPDATE:** I have created a DDEX provider that enables SQLite support (for EF6 only) in Visual Studio 2017, see the how-to guide here: <https://github.com/ErikEJ/SqlCeToolbox/wiki/EF6-workflow-with-SQLite-DDEX-provider> hello chris, - - we are already distributing telerik data access three nuget packages that you can download and try: - - telerik.dataaccess.fluent - package that should be used in your data model project, includes the enhancer; - telerik.dataaccess.core - package with references necessary for any project using telerik data access models and entities - telerik.dataaccess.fluent.sample - package to get you started with writing your fluent mapping using telerik data access. - - these packages are update when we are releasing a new version of the product and you can enjoy updates via nuget package manager. - you can find detailed information about the packages in this documentation article. - if you need assistance setting up your rlinq model to operate using nuget packages just let us know. - - - regards, - viktor zhivkov - telerik -   - - openaccess orm is now telerik data access. for more information on the new names, please, check out the telerik product map. - A few things to try.


1. Use [Variable Tables](http://odetocode.com/Articles/365.aspx) instead -> maybe the import wizard prefers that?
2. Name your return fields.


Try using the following stored proc (untested .. just thinking out loud...)



```
CREATE PROCEDURE dbo.Foo
AS

    SET NOCOUNT ON

    DECLARE @ResultTable TABLE (SomeId INTEGER)

    INSERT INTO @ResultTable
    SELECT DISTINCT Id AS Identity -- Or u can rename this field to anything...
    FROM SomeExistingTableWhichHasAnIdentityField

GO

```

Try that and see if the wizard refreshes, now.


-- 


 Attempt #2 :)


Ok .. when the EF designer/wizard/whatever fails to figure out EXACTLY what my stored proc is suppose to be returning, I usually do the following :-


1. Make sure the stored procedure doesn't exist at all in the EF designer/context, etc. (You have a clean starting point)
2. Open up your stored procedure and `/* /*` comment out *EVERYTHING* after the procedure definition.


eg..



```
ALTER PROCEDURE dbo.Foo
(
    Bar1 INT,
    Bar2 TINYINT,
    ... // whatever u have as your optional input arguments //
)
AS
    SET NOCOUNT ON

    /* 
    .... every thing in here is commented out 
    */
GO

```

Now ...
 3. Add a forced fake return in the stored proc, which (more or less) just *defines* the output structure/fields.


eg..



```
ALTER PROCEDURE dbo.Foo
(
    Bar1 INT,
    Bar2 TINYINT,
    ... // whatever u have as your optional input arguments //
)
AS
    SET NOCOUNT ON

    SELECT 1 AS Id, 1 AS UserId, 1 AS SomeOtherId, 
        CAST('AAA' AS NVARCHAR(350)) AS Name,
        -- etc etc etc..
    /* 
    .... every thing in here is commented out 
    */
GO

```

[and then](http://www.youtube.com/watch?v=K7luMp6lb9M) ...


4. Add this stored proc to your EF designer/wizard/etc... Now the correct fields should be 'determined' by the designer. AWESOME. Yes .. the values are all hardcoded .. but that's ok (so far).
5. Once your happy that EF is now updated right, go back to your stored proc, and remove all hardcoded SELECT (which we did in the above step). Now we remove the comments which we commented out the entire real code. So you should have your original stored proc, back.


... and now EF is updated and doesn't know we've changed the plumbing of your stored proc.


win :)


does this work for ya? hi obin, there is no option to upgrade the vcenter from prism. you will have to use the vmware procedure to upgrade the vcenter. so, you do not need to take any action in prism for the vcenter upgrade and there will be no impact on the nutanix cluster. you can upgrade the esxi hosts from the prism later. Apparently you have a version of NodeJS that does not understand the new features of ES6+, update.  

Way to put on the server, NodeJS and VueCLI at least strange. i think it’s too early to think about h.266.

in any case if it will be supported then you need new hardware. hi,

certain functions will be supported in next jetpack 4.6(r32.6) release. on jetpack 4.5.1, the supported functions are all in

/usr/src/jetson\_multimedia\_api/include/nvbuf\_utils.h all the info you need can be found in http://community.spiceworks.com/topic/291089-6-2-beta-release-candidate-ii-build-now-available-6-2-00797

 we strongly caution you against using the beta in production. if you hit a serious bug you may have to start from scratch!