Skip to content

Instantly share code, notes, and snippets.

@Diaskhan
Diaskhan / AutoMigration.cs
Created February 28, 2021 18:24 — forked from lakeman/AutoMigration.cs
Automatic database migration with EF Core 3.0
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design.Internal;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Migrations.Design;
using Microsoft.EntityFrameworkCore.Migrations.Operations;
using Microsoft.EntityFrameworkCore.Storage;
rowanmiller commented on 31 Jul 2015
@sonofsam I think rather than putting the ModelBuilder in DI you want to construct your model and set it on the DbContextOptions that are registered in DI.
var builder = new ModelBuilder();
// all the code to configure your model
var model = builder.Model;
services.AddEntityFramework()
.AddSqlServer()
.AddDbContext<MyDbContext>(options =>
function convertToWCFFormat(date){
return "\/Date(" + date.getTime()+date.getTimezoneOffset() + ")\/";
}
function convertToWCFFormatFromStr(date){
let _date=new Date(date);
return "\/Date(" + _date.getTime()+_date.getTimezoneOffset() + ")\/";
}
@Diaskhan
Diaskhan / file1
Created April 4, 2019 18:05
Create Dynamicaly class net core
https://softwareengineering.stackexchange.com/questions/93322/generating-a-class-dynamically-from-types-that-are-fetched-at-runtime