Based on your description, you want to create an Entity Framework Core migration.
I assumed that you use sqlserver.
You can refer to the following steps to create the EF Core migration.
First, please create an console app(.Net Core).
Second,please install the following nuget packages:
- Microsoft.EntityFrameworkCore.SqlServer
- Microsoft.EntityFrameworkCore.Design
- Microsoft.EntityFrameworkCore.Tools
Third, please add two classes to your console app.
public class Teacher
{
public int TeaID { get; set; }
public int Age { get; set; }
public string Name { get; set; }
}
public class TeaContext : DbContext
{
public DbSet<Teacher> Teachers { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder
.UseSqlServer(@"Connectionstring");
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Teacher>()
.HasNoKey();
}
}
The Connectionstring is the string that you connect to sql server database.(please create a database first)
Third, you can execute the following command in the Package manager console.
PM> Add-Migration Initial
PM> Update-Database
Finally, you can check the database design.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…