Building REST APIs using ASP.NET Core and Entity Framework Core

ASP.NET Core and Entity Framework Core are getting more and more attractive nowadays and this post will show you how to get the most of them in order to get started with building scalable and robus…

Source: Building REST APIs using ASP.NET Core and Entity Framework Core


ASP.NET Core 1.0 with MySQL and Entity Framework Core

This article shows how to use MySQL with ASP.NET Core 1.0 using Entity Framework Core. Code: Thanks to Noah Potash for creating this example and adding his code to this code base. The Entity Framew…

Source: ASP.NET Core 1.0 with MySQL and Entity Framework Core

Add test data in MVC for development

Sometimes it is easy to using sample data for MVC development.  Overriding Seed method and re-initializing database will save time for developer comparing with executing Code-First migration. Three steps can achieve the goal.

  1. Create a class “SampleDbContextInitializer” inheriting from  DropCreateDatabaseAlways<SampleDbContext>
  2. Override method Seed. e.g.

protected override void Seed(SampleDbContext context)

var addresses = new List<Address>
new Address() { …},
new Address() { …},
addresses.ForEach(a => context.Addresses.Add(a));



3. Add SampleDbContextInitializer to method Application_Start() in Global.asax.cs

   Database.SetInitializer(new SampleDbContextInitializer ());

Some PS Script to install and uninstall Farm WSP

Following PowerShell Scripts are used often to install and deinstall SharePoint WSP Package (Farm Solution) without Visual Studio.

  • Add solution:

Add-SPSolution -LiteralPath “C:\temp\MySolution.wsp”

  • Install solution in GAC with the given WebApplication:

Install-SPSolution –Identity MySolution.wsp –WebApplication http://mywebapplication –GACDeployment

(If solution is only needed to be updated, the command “Update-SPSolution” should be executed, e.g.

Update-SPSolution –Identity Solution.wsp –LiteralPath “C:\temp\MySolution.wsp” –GacDeployment )

  • Uninstall and remove in the certain WebApplication:

Uninstall-SPSolution –Identity MySolution.wsp –WebApplication http://mywebapplication

Remove-SPSolution –Identity MySolution.wsp


Sometimes, Farm Feature should be enabled and disabled by PS.

Enable-SPFeature –Identity “MyFeatureName(or GUID)” –URL http://mywebapplication -Force

Disable-SPFeature –Identity “MyFeatureName(or GUID)” –URL http://mywebapplication

Parameters “-URL” and “-Force” are optional.

More details are included in TechNet site:


Convince WCF To Trust Self-Signed Certificates

Thanks this blog, It solves the problem with my self-signed SSL. I have tried it on a soap service that is implemented with other language and transferred through the proxy server on Nginx, then rewritten by WCF.

Certificate is created by openSSL. It still works on Windows.

When using Self-Signed Certificates in a WCF Service, you may receive the error

SecurityNegotiationException was unhandled: Could not establish trust relationship for the SSL/TLS secure channel with authority ‘localhost:8080’ (your service’s url may be different).

A common cause for the exception is due to the fact that the WCF runtime does not trust Self-Signed Certificates by default. It is, however, possible to override this default behavior.

First we will create a class that does the work of convincing the WCF runtime that our Self-Signed Certificate is trusted.

Now that we have a class that can override WCF’s rejection of a Self-Signed Certificate, we will have the client use that class prior to instantiating the service proxy.

View original post