Previous, we have given tutorial how to publish your .net Core on shared hosting environment. I believe that most of you have heard about that .net Core will run on both windows and Linux Operating System. So, how about Entity Framework 7? EF 7 is being developed with vNext in mind, so it will work with vNext projects. EF7 is also a more light-weight ORM framework that relies on actual code files instead of the old entity diagrams (XML). This is extremely important for a number of reasons:
1. Creating entities is standard classes in .NET.
2. Comparing changes for code files is far easier than XML based documents, so conflicts are much easier to resolve.
3. Still an ORM, so you can still map an existing database, but you get classes.
Sure in the early stages, you lose the entity diagrams, but as a developer it was never something that I found to be truly useful. So, how do you get started? It sounds so easy, but you may run into a few problems.
Setup Your Server First
Please make sure that you setup your server first and install Visual Studio 2015 on your machine. For Visual Studio 2015, you can download it at http://www.visualstudio.com/en-us/downloads/visual-studio-2015-downloads-vs.
Install Git for Windows
Download GitHub via https://git-for-windows.github.io/. Go to start menu, find Git option. Then, pin the Git Bash to the start menu. You should see this image below:
Install KVM
This KVM helps you to manage version of vNext and choose what version to use. Installing KVM is as simple as the following command (use admin command line):
@powershell -NoProfile -ExecutionPolicy unrestricted -Command “iex ((new-object net.webclient).DownloadString(‘https://raw.githubusercontent.com/aspnet/Home/master/kvminstall.ps1’))”
Ensure this is installed correctly. Close your command prompt and re-open it. If you type kvm help you should get a list of commands. Run kvm upgrade just to make sure you have the latest version.
Find Entity Framework 7 Source
The best part of the new .NET stuff is that it is all open source. This means that the development of key components are also open source. This is great because aside from being able to pull the actual code (and update it as necessary, as well as finding bugs early), you can view the source here: https://github.com/aspnet/EntityFramework. I highly recommend going through the following:
– https://github.com/aspnet/EntityFramework/wiki/Entity-Framework-Design-Meeting-Notes
– https://github.com/aspnet/EntityFramework/wiki/Design-Documents
I also like reading the issues and responses as it provides an insight into both the overall development process and the thought process as to why things have been designed that the way they are.
1. Create a directory c:srcEF7.
2. Open Git Shell and navigate to the directory created.
3. Execute the following command: git clone https://github.com/aspnet/EntityFramework.git
Add nightly builds to NuGet
Remember, we are working with pre-release software, so the necessary bits are hosted on non-standard repositories. Mainly, we have to get the vNext repo and the repo for xUnit. To do this simply open Visual Studio and do the following:
Open Tools -> NuGet Package Manager -> Package Manager Settings
Click Package Sources
Click the plus button
Add the vNext feed:
Enter Nightly Builds as the Name andhttps://www.myget.org/F/aspnetvnext/api/v2/ as the Source.
Add the xUnit feed:
Enter xUnit Builds as the Name and http://www.myget.org/F/xunit as the Source.
Publish it
This is a new project on a new version of .NET. There is a file that needs to be run before opening in visual studio that will pull dependencies based on the package configuration. Open up the developer command prompt and navigate to the folder with the code and type:
Build Initialize
This will run lots of commands in the prompt, just look for any errors. IMPORTANT: You may have to uncheck some of the feeds within Visual Studio (go to the Package Manager settings as described above and uncheck the nuget default and xUnit as necessary). However, in order for it to fully complete all three have to be checked in Visual Studio, the process sometimes gets messed up, so just fiddle with checking and unchecking sources until they all work. This is because NuGet is tied to Visual Studio, don’t get me started on that topic, that is an epic post on its own.
Eventually the output should be as follows with no errors:
If it is not successful you should see an error instead of Target initialize.
Open the solution in Visual Studio
Open up Visual Studio 2015 and go to file open and open the solution file. Now you should be able to build the solution successfully. NuGet will do its thing and eventually it should build successfully. Look at the tests and understand the architecture to help get a head-start with working with the latest version of .NET and Entity Framework.
Publish Your Entity Framework on Hosting Server
If you want to build you entity framework 7 on hosting server, you may take a look at ASPHostPortal, HostForLIFEASP.NET, and UKWindowsHostASP.NET. For more information about their hosting business, you can see the explanation how to choose best and cheap Entity Framework 7 hosting.
[crp]