Of course, I wanted to stop everything and fiddle around with the early bits of EF7. Here’s a look at just getting at EF7 and the source.
EF7 Assemblies on Nuget
EF7 APIs are being built nightly and available via MyGet. You can have NuGet package manager subscribe to the proper feed by adding it into the Package Sources in Visual Studio’s Options UI. I named mine ASPNET EF7 Nightly Myget, although the feed is really for all of ASP.NET. The source url is https://www.myget.org/F/aspnetvnext/api/v2.
With that set up, you can pull from that source from the package manager like so:
Note that I’m using VS2013 and it was necessary to be sure I had the latest NuGet extension installed. I didn’t at first and got an error message (indicating the exact problem about the version) when I was trying to install the packages.
Here are the EF7 assemblies after I’ve filtered on data.entity:
Notice that the assemblies aren’t all in one big entityframework.dll file. You get to pick and choose the assemblies that drive big features e.g., migrations. The rest are for various ways of storing data. If you want EF7 to store data in memory only, then just grab that package. Want to use SQL Server? Grab that package.
I chose Microsoft .Data.Entity and InMemory, but then realized I didn’t know how to use InMemory. So instead, I decided to start over by downloading the full EF7 project along with its tests because I know I can learn a lot from the tests.
A Look at the EntityFramework solution
I went to the Github page for EF7 at https://github.com/aspnet/entityframework and downloaded the ZIP file for the solution.
You’ll find that there are no project files (e.g. csproj) in the solution and you can’t just open it up right away. In fact the solution is very minimal. Instead, each project has a project.json file with information about the dependences of that project. Here, for example, is the project.json file for the functional tests project of the solution:
In the downloaded files, you’ll find a “build.cmd” file in the root folder. This calls another powershell file which will run through the projects, grab all of the necessary assemblies from NuGet and create the relevant csproj files for all of the projects. I’m sure it does plenty more as well.
After this is completed, open the solution and you’ll find that the Entity Framework source code has two sets of projects. One set targeted at Project K which supports projects in a lightweight manner via NuGet, the other targeted at .NET 4.5. If you look at the references in the K10 projects, you’ll find that they all point to assemblies that are in your project folders. In other words, every one of them is a NuGet package downloaded into your project. Even System.Runtime and System.Linq.
In the .NET 4.5 projects, you’ll find a mix of NuGet files (e.g. System.Data.Entity) and core .NET assemblies that are coming from the GAC.
The tests however are all .NET 4.5 based.
Here is an overview of what’s in the full solution: both sets of EntityFramework projects (InMemory, Entity, Migrations, Relational, SQLite and SqlServer). And a set of unit tests and functional tests for each of those projects:
The sun has come out so time to go! More to come though!
Oh, one last thing before I bolt. I found this amusing bit of test data in the tests:
customer.name = "Unikorn, The Return";
Sign up for my newsletter so you don't miss my conference & Pluralsight course announcements!
Interesting to see a Microsoft.Data.Entity.SQLite in the NuGet packages list. I currently use the System.Data.SQLite provider, but it has some drawbacks (e.g. I couldn’t find out how to create the tables directly from my Code First model, had to write my Create Table SQL by hand).
A short google search didn’t bring up much about Microsoft.Data.Entity.SQLite. Any insights on what is planed there?
not sure yet. Assuming that it will have the same basic features we already have. Currently experimenting with it myself.
Ahh…this doc shows that migrations are not enabled yet but you can just use database.Create to do the job for now: https://github.com/aspnet/EntityFramework/wiki/Using-EF7-in-Windows-Phone-Store-Applications
Just a quick note on how the csproj files are actually generated. The solution uses <a href="https://github.com/sakeproject/sake" title="Sake" and KoreBuild to create them, the build.cmd file only uses powershell to get the latest version of nuget.
Nice! Thanks Stuart! I’m sure if I’d paid more attention to Project K I may have known that. Or just read the file contents. 🙂