I'm trying to make a Generic CRUD for my project. However as I used DataBaseFirst I do not see how to have a generic class of Entity that can be inherited. Well it does not make the slightest sense, eventually when I upgrade the bank, it would have to go into all the more than 60 classes of the tables and add the inheritance again. I want the Entity classes that the Entity Framawork generated as pure as they were generated.
ButasyoucanseeIhavethispropertyproblemnotbeingdefined,sinceasIsaidIdonotwanttohaveanythinglikea"General Entity".
Does anyone know of any way to achieve this? Type has some class that Entity uses beneath the wads that can be used in the where constraint. Or maybe if instead of Generics I used Reflection? Any idea?
Edited: Added Code.
public class DaoEF<TEntity> : IDaoEF<TEntity>
where TEntity : class
{
public GPSdEntities _dbContext { get; set; } = new GPSdEntities();
public async Task<TEntity> GetById(int id)
{
return await _dbContext.Set<TEntity>()
.AsNoTracking()
.FirstOrDefaultAsync(e => e.Id == id);
}