I am currently using EntityFrameworkCore 2.0.0.
The application I am creating is an online store product scraper. All stores are saved in the database, and each store has a scraper that implements IStoreScraper
.
This is my store model:
public class Store
{
public int Id { get; set; }
public string Name { get; set; }
[NotMapped]
public IStoreScraper StoreScraper { get; set; }
}
I was wondering if it is possible to add the correct IStoreScraper
object to the Store
object when it is fetched from the database. Either by a value from the database or something else.
I also looked into injecting this in the constructor of the model, however, this violates the Dependency Injection pattern because each class has its own, already known, implementation.
Maybe I should even look at it from another perspective because this code should not be in a model class? Any ideas?