Code First to existing DB
How-to code-first
Reverse engineer your model
Scaffold-DbContext "Server=(localdb)\mssqllocaldb;Database=Blogging;Trusted_Connection=True;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Modelsusing System;
using System.Collections.Generic;
namespace EFGetStarted.AspNetCore.ExistingDb.Models
{
public partial class Blog
{
public Blog()
{
Post = new HashSet<Post>();
}
public int BlogId { get; set; }
public string Url { get; set; }
public ICollection<Post> Post { get; set; }
}
}Last updated