I have an existing database that we are using EF Core and trying to generate more “business” name for our entities. I see how you can use data annotations when using the code-first model, but am not seeing a way to use this feature with the database-first model.
For example I have a table name tblStudents
, but I want the entity to be Students
. If I’m using code-first, I can have a file called Students.cs
as shown below, and when I generate to the database it would create a table called tblStudents
.
using System.ComponentModel.DataAnnotations.Schema;
namespace MyDatabase.Entities
{
[Table("tlbStudents")]
public class Students
{
public int StudentId { get; set; }
public string? FirstName { get; set; }
public string? LastName { get; set; }
}
}
I want to go the other direction. I want to scaffold from the database and have it generate a file Students.cs
and point to table tblStudents
. With the older EF (not core), there was a wizard that you could do this with, but I’m not seeing anything in the documentation to support this.
Is it just not possible?