Skip to content

Instantly share code, notes, and snippets.

View merken's full-sized avatar

Maarten Merken merken

View GitHub Profile
@merken
merken / MyDbContext.cs
Last active August 18, 2017 08:04
Entity Framework Core: Data type 'nvarchar' is not supported in this form. Either specify the length explicitly in the type name, for example as 'nvarchar(16)', or remove the data type and use APIs such as HasMaxLength to allow EF choose the data type.
public class MyDbContext : MyContext
{
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<MyEntity>(entity =>
{
entity.Property(e => e.MyProperty)
.HasColumnType("nvarchar(4000)");
@merken
merken / MyDbContext.cs
Last active March 8, 2021 13:46
Providing a connection string in EF core
public class MyDbContext : MyContext
{
private readonly string connectionString;
public MyDbContext(string connectionString) : base()
{
this.connectionString = connectionString;
}
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
@merken
merken / project.csproj
Created August 18, 2017 08:17
ef core references
<Project Sdk=”Microsoft.NET.Sdk”>
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include=”Microsoft.EntityFrameworkCore.Design” Version=”2.0.0" />
<PackageReference Include=”Microsoft.EntityFrameworkCore.SqlServer” Version=”2.0.0" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include=”Microsoft.EntityFrameworkCore.Tools.DotNet” Version=”2.0.0" />
@merken
merken / UnitTest1.cs
Created August 18, 2017 10:23
Simple unit test
public class UnitTest1
{
[Fact]
public void Test1()
{
Assert.Equal(1, 1);
}
}
@merken
merken / Dockerfile
Last active August 24, 2017 11:38
Dockerfile Merken.NetCoreBuild.App
FROM microsoft/aspnetcore
# set up network
ENV ASPNETCORE_URLS http://+:5000
WORKDIR /app
EXPOSE 5000
COPY . /app
ENTRYPOINT ["dotnet", "netcoreapp.dll"]
@merken
merken / Dockerfile
Last active September 22, 2017 20:13
Dockerfile for jenkins with netcore runtime
# this is the jenkins version, to upgrade the base image, alter the argument below
ARG JENKINS_VERSION=2.60.2
FROM jenkins:$JENKINS_VERSION
LABEL name "netcorebuild"
MAINTAINER Maarten Merken
ARG NET_CORE_APP_NAME=netcoreapp
ARG JENKINS_CLI_URL=https://repo.jenkins-ci.org/public/org/jenkins-ci/main/cli/$JENKINS_VERSION/cli-$JENKINS_VERSION-jar-with-dependencies.jar
# get rid of admin password setup
ENV JAVA_OPTS="-Djenkins.install.runSetupWizard=false"
<?xml version='1.0' encoding='UTF-8'?>
<flow-definition plugin="workflow-job@2.11">
<actions/>
<description></description>
<keepDependencies>false</keepDependencies>
<properties>
<org.jenkinsci.plugins.workflow.job.properties.PipelineTriggersJobProperty>
<triggers>
<hudson.triggers.SCMTrigger>
<spec>* * * * *</spec>
@merken
merken / Jenkinsfile
Last active December 3, 2018 12:22
netCoreBuild Jenkinsfile
import groovy.json.JsonSlurper
VERSION_NUMBER = ""
/** Pipeline **/
node {
ws('netcore') {
try{
stage("scm pull") {
deleteDir();
@merken
merken / Jenkinsfile
Last active December 3, 2018 12:20
basic Jenkinsfile
//GLOBAL VARIABLE
VERSION_NUMBER = ""
/** Pipeline **/
node {
ws('myapp') {
try{
stage("scm pull") {
cloneRepo();
VERSION_NUMBER = "1.2.3"
currentBuild.displayName = "$VERSION_NUMBER";
using System;
using System.Data;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc.Filters;
namespace txn
{
public class UnitOfWorkFilter : IAsyncActionFilter
{
private readonly IDbTransaction transaction;