Category Archives: dotNET

Updated My EFCore / WebAPI / PostreSQL / XUnit Repo to 1.1

Today was dedicated to updating my long running repository sample that I started when EF Core was EF 7  to the newest version of EF Core: 1.1. Here is the updated repo: https://github.com/julielerman/EFCore-ASPNetCore-WebAPI-RTM.

Phase one of this update continues to use project.json.

In addition to updating the version #s of  the Nuget package references, I also made some changes to the code to reflect a few new features.

Pay attention to the tooling packages. In the tools section, the package name has changed – note DotNet at the end –  and the version is currently 1.0.0-preview3 even though IIS version is preview2.

 "tools": {
   "Microsoft.AspNetCore.Server.IISIntegration.Tools": 
       "1.0.0-preview2-final",
   "Microsoft.EntityFrameworkCore.Tools.DotNet":
       "1.0.0-preview3-final"
 },

Also in the dependencies, the EFCore Design package is 1.1.0 like the rest of EFCore. That’s part of the EF APIs, not tooling.

Code changes ….

You’ll discover the DbSet.Find method and change tracker Load method in use in the repository class. These were both added in to EF Core 1.1.

I modified the WeatherEvent class to fully encapsulate its Reactions collection using the support for mapping to IEnumerable. That resulted in some changes to constructors and the addition of an AddReaction method and a local variable.

Unrelated to EF Core, I also modified the SeedData.cs class. It reads a hard coded seeddata.json file to read in seed data. That data used old dates. I wanted the data to show current dates to help me tell that I really and truly pushed new data into the database. Since the Date property of WeatherEvent is private, they way I went about this was to read the raw JSON and update the date value that way then save the raw JSON back to the original file. Then I deserialize the JSON with a current range of dates into a set of WeatherEvents. This also means that I added Delete/Create database back in so the database gets thrown away and recreated/reseeded every time you start up the application.

The tests are also update to use the latest packages. In addition to changing the versions, I had to add a reference to an older package (InternalServices) as its dependency has not yet been updated in xunit.

Here’s the full project.json for the test project since I had to do a bunch of googling to figure it out.

{
 "version": "3.0.0-*",
 "description": "Tests for simple app using aspnetcore, efcore and   
                  postgresql. developed and run on OSX.",
 "authors": [ "Julie Lerman" ],
 "testRunner": "xunit",
 "dependencies": {
   "Microsoft.EntityFrameworkCore.InMemory": "1.1.0",
   "src": "3.0.0",
   "xunit": "2.2.0-beta4-build3444",
   "dotnet-test-xunit": "2.2.0-preview2-build1029",
   "Microsoft.DotNet.InternalAbstractions":"1.0.0"},
 "frameworks": {
 "netcoreapp1.0": {
   "dependencies": {
     "Microsoft.NETCore.App": {
     "type": "platform",
     "version": "1.1.0"
     }
   },
   "imports": [
     "dnxcore50",
     "portable-net45+win8"
     ]
   }
  }
}

I hope you find this repository useful to see EF Core 1.1 in action.

Oh and as per a tweet by Brad Wilson, I added SDK to my global.json file!

Now I have to go learn about why this is important. Clearly it is!

 

Video of My .NET on a Mac Demo at DotNetFringe

Last week at the awesome DotNetFringe conference in Portland, Oregon, I did a 30 minute demo of building an ASP.NET Web API with Entity Framework using Visual Studio Code on my lovely MacBookPro. So it’s .NET on a mac (coding, debugging and running). It is *that* cross platform.

I also talked about some of the features of ASPNetCore and EFCore. I used other cross platform stuff like JetBrains’ DataGrip IDE for interacting with numerous databases on numerous platforms, PostgreSQL database, xunit for testing and more!

It was a boatload of fun and it’s on YouTube:

The solution I showed in the demo is in my github repository: julielerman/EFCore-ASPNetCore-WebAPI-RTM

My Twitter Notes from Scott Guthrie Keynote at DevConnections

Here are my twitter notes from the Scott Gutrhie keynote at DevConnections yesterday morning.

I have just done a quick copy/paste job. Read them from the bottom up!

 VS2010 Generate Class on the fly: RT @bsuzy: @julielermanvt excellent video on that here http://bit.ly/3J0AzW (via http://bit.ly/YTDwU)

  •  
  •  

     

  • and.. @scottgu is repeating that LINQ to SQL is FULLY SUPPORTED in .NET 4 . Not a new message, but people believe him. Glad when he says it

     

     

  •   #devconnections – @scottgu so far showing some of the awesome improvements to the text editing (searching, etc) in VS2010 IDE from TweetDeck

  •   in @scottgu keynote at #devconnections – vs2010 & asp.net 4. not a lot of people (who have normal lives) here have installed the beta yet
  • and no onto ASP.NET MVC (@scottgu at #devconnections…..)

    Notes from Scott Guthrie ASP.NET 4/VS2010 keynote

    Update: Added the tweets to a blog post here.

    I’m at DevConnections and sat in on Scott Guthrie’s keynote.

    I tweeted a lot of notes throughout the session.

    http://www.twitter.com/julielermanvt

    I’ll try to consolidate them at some point.

    There’s a lot coming from te #devconnections hash on twitter. You don’t need to have an account to read this stuff. I didn’t use the hashtag on all of my tweets from the session, thoughI tried.

    After three years, I discover how to choose a ClickOnce Icon in MageUI

    This is completely insane. Someone from Romania emailed me about selecting an icon file for a ClickOnce deployment so that the application icon is used for the installation and for the shortcut.

    He had tried my hack that I have blogged about, written about in CoDe Magazine and shown in conference presentations. The hack requires manual editing of the manifest file and I learned it in the forums.

    I had never been able to discover any other way to do it.

    There is a new version of the MAGEUI tool, the UI for building ClickOnce manifests, so I went in to see if there was anything different with respect to that.

    On the file page, things looked the same as always:

    So I was staring at it and looking at the file type column and wishing I could use it. But it’s always appeared to be disabled. While I was staring and thinking, I was clicking on that and on the second click, a drop down list appeared.

    And when I clicked the arrow, there it was!

    Understand, that in a normal UI property sheet like this, the arrow would be visible when you first click the cell.

    So I went back to the previous version of MAGEUI and after two clicks, no dropdown. But guess what, one more click and there it was!

    All this time? All of the blog posts I wrote, the article in CoDe Magazine. Nobody every emailed me to tell me “oh, here’s how”. You’d think…  Clearly it’s not THAT obvious! Oh well.

    I haven’t ever seen this documented (though I sure wish there was a copy of Brian Noyes ClickOnce book nearby to see if he knew).

    Well, there you have it.