1

We have a large solution that was developed in VS2010. I upgraded it to work in VS2013 last week, but left the EF version at 4, as upgrading to a later version would require a lot of changes, and we don't want to do that just yet.

At that stage, I was able to update the model to reflect some database changes. When I started the wizard, it took me straight to the part where you choose the tables, as it had always done.

I've just made some more database changes, and tried to update the model again, and the wizard is asking me for a connection string. I have no idea why, as this model is about three years old, and we haven't needed to specify the connection string since we set it up, as it's stored in App.config.

Even if I specify the connection details, it's now asking which version of EF I want to use, and only offering me EF5.0. There is a radio button for EF6.0, but it's disabled. EF4 just doesn't show up as an option.

I don't want to upgrade EF at all, I want to carry on working with EF4 for the moment. This worked fine last week, why is it now insisting I upgrade? Upgrading would require massive changes that we can't afford to do right now.

I saw another question that addressed a related issue, but that isn't the problem here. I'm not getting anywhere near the code generation stage, as it won't even let me choose which tables to add.

I opened the solution in VS2010, and the wizard went straight to the part where you choose the tables, which is what should be happening in VS2013.

Anyone any ideas? All development has come to a standstill as we can't do anything.

Community
  • 1
  • 1
Avrohom Yisroel
  • 8,555
  • 8
  • 50
  • 106
  • If i could have a database and solution then What i may try is to upgrade from VS2010 to VS2012 first. Then if it works then i might upgrade the later solution to VS2013. Check http://msdn.microsoft.com/en-us/magazine/jj618295.aspx – Kamran Shahid Jan 18 '15 at 17:37
  • Out of curiosity, what "massive changes" do you think you have to do to go from EF4 to EF6? Are you using Self-Tracking Entities? If so, there are still templates available to generate STE's. – Erik Funkenbusch Jan 18 '15 at 18:18
  • Also, when you say EF4 do you mean EF4.0 or EF4.1? – Erik Funkenbusch Jan 18 '15 at 18:32
  • @ErikFunkenbusch we're using EF4.1 with STEs, and as far as I understand it, we would have to change our data access code, as it uses object contents, which are replaced in EF6. That would mean changes across all of our DALs, which is more than we want to do right now. We're trying to ease this migration, rather than upgrade everything at once. – Avrohom Yisroel Jan 18 '15 at 18:48
  • No, ObjectContext still exists in EF6. That is not true. What is gone is that STE's are deprecated, however it's still possible to use them with templates you can get from Nuget. See https://entityframework.codeplex.com/discussions/446660 – Erik Funkenbusch Jan 18 '15 at 19:09
  • @ErikFunkenbusch thanks for that link. I thought that the ObjectContext had gone forever, and we would have to change all our code to use DbContext. Although we have a lot of problems with STEs, we are too committed to them to change now, so if we can carry on using them with EF6, that will help a lot. Depending on how different the TEs are, we may switch to those as well. – Avrohom Yisroel Jan 18 '15 at 20:47
  • No, ObjectContext is not gone in EF6. It will be gone EF7, but EF7 and EF6 will coexist for a long time even after EF7 is released. – Erik Funkenbusch Jan 18 '15 at 20:49

2 Answers2

2

Oddly enough, the wizard was lying! OK, maybe that's not so odd, but it was lying all the same.

I decided to try it out and see what would happen if I let it upgrade to EF5.I set the connection properties and left the radio button set at EF5.0 (not that I had any other choice). When it had updated the model, I had a look to see what it had changed, and it hadn't! The solution still uses EF4 as before, and if I update the model now, it takes me straight to where you choose the tables.

So, it looks like this is some sort of bug, or weird one-off behaviour, but it seems to work now.

Thanks to all who replied. Let this be a warning to anyone trying this.

Avrohom Yisroel
  • 8,555
  • 8
  • 50
  • 106
1

Because you installed VS2013 on your machine it installed .NET Framework 4.5 (if you did not have one before). The EF version (core components i.e. System.Data.Entity.dll) that is part of the .NET Framework 4.5 is EF5 (EF4 was in .NET Framework 4). Note that .NET Framework 4.5 is an in-place update meaning that once you install .NET Framework 4.5 you no longer run anything on .NET Framework 4 since you don't have it on the box. Targeting .NET Framework 4 in you application merely ensures that you are not using APIs that are not available in this .NET Framework version but when it comes to runtime the app will run on whatever is installed on the box. Back to EF - the core components between EF4 and EF5 are backwards compatible so an EF4 app should work without changes after upgrading to EF5. The reason why EF6 was disabled in the wizard was that your app has already a reference to System.Data.Entity.dll meaning you already used EF5. Having both EF5 and EF6 is possible but not recommended because it gets very tricky. You can read more about changes to the EF designer in VS2013 in my blog post on this.

Pawel
  • 31,342
  • 4
  • 73
  • 104
  • Thanks for the suggestion, but this can't be the right answer, because as I mentioned in my question, I was able to update the model quite a few times after moving the solution to VS2013. I have no idea why it suddenly popped up with this dialog, but it wasn't right from the start. Anyway, as you can see from my own answer, the problem turned out not to be a problem at all, it just looked like one! – Avrohom Yisroel Jan 21 '15 at 17:26