简体   繁体   中英

EF 3.5 to EF 6 Migration?

First off, I need to state that I'm a firmware guy so I apologize for my ignorance on this topic. I'm likely not providing all the relevant information. I'm looking for some advice on how to proceed with a problem I'm facing.

I have a project that was written in VS 2008 that targets .NET3.5 and EF 3.5. There is a database query that seems to be exponentially related to the size of the database table. It is a read-only query. I see that new versions of EF have the .AsNoTracking() which appears to drastically improve performance on such queries.

  1. Can I achieve the equivalent of .AsNoTracking in EF 3.5 somehow?

  2. Should I consider updating the project to EF 6 to gain this new functionality?

  3. If upgrading is the appropriate direction, in general how much work is involved? Or maybe the better question, what changes are necessary?

Should I consider updating the project to EF 6 to gain this new functionality?

Yes. EF 3.5 is definitely too old, and too bad-to-begin-with to mess with. You leave it alone, or you move to EF6 (or EF Core). Note that upgrading EF requires moving to .NET 4, and a newer version of Visual Studio (or perhaps VS Code).

what changes are necessary [to upgrade]?

Generally, upgrade the project to .NET 4.X using Visual Studio 2017. Add a new EF 6 model to the application using the Code-First to an Existing Database workflow , making sure to generate the new Entity Types into a different C# namespace. Then go through the application and change all code that references the 3.5 EF model, to reference the new EF 6 model. Once you've gotten that working, remove the EF 3.5 model from the application.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM