-
-
Save explorer14/a522fa4437bd6289458b5e923677af09 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static void Main(string[] args) | |
{ | |
DbContextOptionsBuilder<MyContext> builder = new DbContextOptionsBuilder<MyContext>(); | |
builder.UseSqlServer("<connection string>"); | |
Guid blogId; | |
Guid postIdToRemove; | |
// Let's create the Aggregate root first i.e. Blog | |
using(var ctx = new MyContext(builder.Options)) | |
{ | |
var blog = new Blog("Aman'sThoughts.com"); | |
ctx.Blogs.Add(blog); | |
ctx.SaveChanges(); | |
blogId = blog.Id; | |
} | |
// Now let's publish some posts in the blog | |
using (var ctx = new MyContext(builder.Options)) | |
{ | |
var blog = ctx.Blogs.Where(x => x.Id == blogId).Include(x => x.Posts).FirstOrDefault(); | |
blog.CreatePost("Migrating from EF Core 2. to EF Core 3.0", "Its a bit broken!"); | |
blog.CreatePost("Migrating from .NET Core 2.2 to NET Core 3.1", "Went kinda ok!"); | |
ctx.SaveChanges(); // <--- this is where it blows up! | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment