Skip to content

Instantly share code, notes, and snippets.

public ExampleDbContext(DbContextOptions options) : base(options)
{
}
public ExampleDbContext(DbContextOptions options) : base(options)
{
}
public DbSet<Person> Persons { get; set; }
using EFCoreSeparateProject.Core.Domain;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace EFCoreSeparateProject.Infrastructure.EntityConfigurations
{
public class PersonConfiguration : IEntityTypeConfiguration<Person>
{
public void Configure(EntityTypeBuilder<Person> builder)
{
using EFCoreSeparateProject.Core.Domain;
using EFCoreSeparateProject.Infrastructure.EntityConfigurations;
using Microsoft.EntityFrameworkCore;
namespace EFCoreSeparateProject.Infrastructure
{
public class ExampleDbContext : DbContext
{
public ExampleDbContext(DbContextOptions options) : base(options)
{
{
"SqlConnectionString": "Server=127.0.0.1,5433;Database=EFCoreSeparateProjectDb;User Id=sa;Password=yourStrong(!)Password;"
}
using EFCoreSeparateProject.Infrastructure;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
using Microsoft.Extensions.Configuration;
using System.IO;
namespace EFCoreSeparateProject.Migrations
{
public class ExampleDbContextFactory : IDesignTimeDbContextFactory<ExampleDbContext>
{
{
"ConnectionStrings": {
"DbUpSqlConnectionString": "Server=127.0.0.1,1589;Database=sqldb-databasereleaseautomation;User Id=sa;Password=YourPassword123;"
}
}
@joewashington75
joewashington75 / Program.cs
Created May 26, 2020 20:25
DbUp Program.cs
using DbUp;
using Microsoft.Extensions.Configuration;
using System;
using System.Linq;
using System.Reflection;
namespace DatabaseReleaseAutomation.DbUpDemo
{
class Program
{
@joewashington75
joewashington75 / shared-access-signature-token.ps1
Created July 13, 2021 14:29
Generating a shared access signature token using Powershell
$URI="https://{{service-bus-name-here}}.servicebus.windows.net/{{queue-name-here}}"
$Access_Policy_Name="{{access-policy-name-here}}"
$Access_Policy_Key="{{access-policy-key-here}}"
$Expires=([DateTimeOffset]::Now.ToUnixTimeSeconds())+7568640
$SignatureString=[System.Web.HttpUtility]::UrlEncode($URI)+ "`n" + [string]$Expires
$HMAC = New-Object System.Security.Cryptography.HMACSHA256
$HMAC.key = [Text.Encoding]::ASCII.GetBytes($Access_Policy_Key)
$Signature = $HMAC.ComputeHash([Text.Encoding]::ASCII.GetBytes($SignatureString))
$Signature = [Convert]::ToBase64String($Signature)
$SASToken = "SharedAccessSignature sr=" + [System.Web.HttpUtility]::UrlEncode($URI) + "&sig=" + [System.Web.HttpUtility]::UrlEncode($Signature) + "&se=" + $Expires + "&skn=" + $Access_Policy_Name
@joewashington75
joewashington75 / apim-to-azure-service-bus-policy.xml
Created July 13, 2021 14:53
Writing to Azure Service Bus using APIM Policy
<!--
IMPORTANT:
- Policy elements can appear only within the <inbound>, <outbound>, <backend> section elements.
- To apply a policy to the incoming request (before it is forwarded to the backend service), place a corresponding policy element within the <inbound> section element.
- To apply a policy to the outgoing response (before it is sent back to the caller), place a corresponding policy element within the <outbound> section element.
- To add a policy, place the cursor at the desired insertion point and select a policy from the sidebar.
- To remove a policy, delete the corresponding policy statement from the policy document.
- Position the <base> element within a section element to inherit all policies from the corresponding section element in the enclosing scope.
- Remove the <base> element to prevent inheriting policies from the corresponding section element in the enclosing scope.
- Policies are applied in the order of their appearance, from the top down.