Open hstridh opened 3 years ago
You should be able to define your MyEntity in a separate file (MyEntity.cs). Then, if you make your DbContext a partial class
Settings.DbContextClassModifiers = "public partial";
This will allow you to add more functionality to your DbContext class in a separate file that is not generated.
partial class MyDbContext
{
public DbSet<MyEntity> MyEntities {get;}
}
Hi,
I trying to run a raw sql statement and map to an entity as describe here: https://docs.microsoft.com/en-us/ef/core/querying/raw-sql
But I would like to map to a custom entity so that I can do: var customEntities = context.MyEntity .FromSqlRaw("{AComplicatedSqlStatement}") .ToList();
But how can I add a custom entity like below to the context? Is there a way to specify this in the database.tt file?
public class MyEntity { public string a {get;set;} public string b {get;set;} public string c {get;set;} }