See the latest post on this here.
I’ve updated globally to Bower 1.4 on Windows 8.1 machine for this post.
npm update -g bower
NeoSample-ASPNET5 now uses Entity Framework InMemory datastore provider by default so just download and run on the latest CLR x86 runtime. You can switch to the SQL Server provider easily with a few lines of code.
The NeoSample-ASPNET5 Starter app is up on GitHub.
This is the sample based on the ASPNET 5 Starter App created by the Visual Studio 2015 template which has been modified to compile against the current beta4 nightly builds.
Always check the readme to see current status, UP means you can compile and run with the latest aspnetvnext nightly builds, DOWN means I’m waiting on something to be resolved.
By default the app now uses the EF InMemory provider so you do not need to apply the CreateIdentitySchema migration to use. Switch to SQL Server and apply migration when you need to.
Here is some guidance on setting up and running the app.
Currently the app does not run with Visual Studio 2015 CTP 6 because of the dnx naming that was done. The next release of VS2015 should allow the opening and running of the NeoSample-ASPNET5.
This is my setup but doesn’t mean everything is needed, I just want you to have any tools you may need in your tool belt.
If you setup Visual Studio 2015 CTP6 and create an ASP.NET 5 Web App you should wind up with a .k directory with packages and runtimes under it. I like also having the .k\bin folder which holds the kvm.cmd and kvm.ps1 files. This allows you to manage the installation of the dotnet runtimes. Use this post but instead of dotnetsdk use kvm. Also the default directory is now .k and not .dotnet.
Running kvm setup now installs the version manager into your user profile directory (in .k\bin) and adds the KRE_HOME to your user profile.
The latest runtime 32-bit Asp.Net 5.0. will be used when we open the solution using VS2015 CTP 6 which we do later.
Navigate your .k\bin folder holding kvm files and type
This should show you a list of runtimes installed in .k and which one is active.
kvm upgrade -arch x86 -r CLR -a default
Very important that the latest runtime shows as active and has default alias as shown above. Also VS2015 prefers we have x86 CLR as active and default to open the solution.
No go back to the Environment Variable window as seen above and put the path to the runtime in variable Path under User variables. My Path looks like this.
Notice I have a path to my .k\bin folder so I can run the kvm command from anywhere. The runtime bin makes sure we run the correct k command when we are in our project directory.
Close all command prompt windows and open a new one so you pick up the latest environment settings.
You should also be able to type
and it will display the runtime version you are using. I see
on my machine.
Now let’s download the sample from github NeoSample-ASPNET5 here. You’ll see download zip file on bottom right.
Open the zip file and place in one of your folders.
Now let’s go to the folder in the command prompt window. Find the project directory for NeoSample under src directory. On my machine I find it here
This should still show the current runtime version.
If all looks good so far type (enter multiple times until no package complaints)
kpm restore makes sure all the packages are downloaded and installed. You should see alot of activity after entering this.
k ef -h
This should display the Entity Framework version you are using and it should be a beta4 version.
I see this but you should have a later version by now
If we now go to the project directory under test, on my machine it is
to load all packages. You may need to run a few times.
You need to set the SQL Server connection string you will be using in the DbContext class ApplicationDbContext if you decide to apply the migration to SQL Sever. By default is using the InMemory provider to load the EF data model.
By default the Entity Framework InMemory datastore is used. This is sufficient for running the app. To use SQL Server make the following code changes to the NeoSample project.
In the ApplicationDbContext class under DbContexts folder in the OnConfiguring method, comment out the call to UseInMemoryStore and uncomment UseSqlServer. Set the connection string for UseSqlServer for your database.
In Startup class in the ConfigureServices method comment out .AddInMemoryStore() and uncomment .AddSqlServer().
Back in command prompt under src\NeoSample directory type
k ef migration list
You should see
This is the migration I created already for you.
Now lets apply this migration and create the database with the following command
k ef migration apply CreateIdentitySchema -c ApplicationDbContext
We just applied the migration in the database to our database. This is the identity schema that tracks accounts for login.
Now we should be able to run the app right from here, type
This will host our app and start it for us.
Now open url
Life is good.