Summary
I have modified a nopCommerce solution to include a new Entity with a CodeFirst Approach, it has successfully updated the Database as shown in the image below.
Photo that database has table updated
When I attempt to access the repository table, which is inserted through AutoFrac, I get rows returned by the repository but with all columns showing null values. Note that the number of rows in the table is the same as what is seen on the database table, so it seems to have been connected but not showing the values.
{
public partial class NutrientService : INutrientService
{
#region fields
protected readonly IRepository<ProductNutrient> _productNutrientRepository;
#endregion fields
#region Ctor
public NutrientService(IRepository<ProductNutrient> productNutrientRepository)
{
_productNutrientRepository = productNutrientRepository;
}
#endregion Ctor
public IList<ProductNutrient> GetNutrients()
{
var query = from p in _productNutrientRepository.Table
select p as ProductNutrient;
var list = query.ToList();
return list;
}
public IList<ProductNutrient> GetNutrientsByProductID()
{
var query = from p in _productNutrientRepository.Table
select p as ProductNutrient;
var list = query.ToList();
return list;
}
}
}
Debugging showing Null values returned from repository
Table Definition in SQL Management Studio
public class ProductNutrient : BaseEntity
{
public int NutrientID;
public int ProductID;
public string Nutrient;
public bool ShowLessThan;
public decimal Value;
public string Unit;
}
}
Repository does work with other tables, but here is the repository code anyway
/// </summary>
public virtual IQueryable<TEntity> Table => Entities;
/// <summary>
/// Gets an entity set
/// </summary>
protected virtual ITable<TEntity> Entities => _entities ?? (_entities = _dataProvider.GetTable<TEntity>());
#endregion
}