title: No suitable constructor found for entity type string
body: <p>Yesterday I came her with a similar question about my own made entity type that head some errors. I fixed up these errors but now it throws one on entity type string and I have absolutely no clue how to fix this.</p>
  
  <p>Full exception: </p>
  
  <blockquote>
    <p>System.InvalidOperationException: 'No suitable constructor found for entity type 'string'. The following parameters could not be bound to properties of the entity: 'value', 'value', 'startIndex', 'length', 'value', 'value', 'startIndex', 'length', 'value', 'value', 'startIndex', 'length', 'value', 'startIndex', 'length', 'enc', 'c', 'count', 'value'.'</p>
  </blockquote>
  
  <p>This gets thrown when I launch my application: I've written a data seeder to get some data in my database. I've scoped this class in my <code>ConfigureServices</code> and used it in the <code>Configure</code> method.</p>
  
  <pre><code>public void ConfigureServices(IServiceCollection services) {
          services.Configure&lt;CookiePolicyOptions&gt;(options =&gt; {
              // This lambda determines whether user consent for non-essential cookies is needed for a given request.
              options.CheckConsentNeeded = context =&gt; true;
              options.MinimumSameSitePolicy = SameSiteMode.None;
          });
  
          services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
          services.AddDbContext&lt;ApplicationDbContext&gt;(options =&gt;
             options.UseSqlServer(
                 Configuration.GetConnectionString("DefaultConnection")));
          services.AddScoped&lt;IRatingRepository, RatingRepository&gt;();
          services.AddScoped&lt;IReservationRepository, ReservationRepository&gt;();
          services.AddScoped&lt;DataSeeder&gt;();
      }
  
      // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
      public void Configure(IApplicationBuilder app, IHostingEnvironment env,DataSeeder seeder) {
          if (env.IsDevelopment()) {
              app.UseDeveloperExceptionPage();
              app.UseDatabaseErrorPage();
          } else {
              app.UseExceptionHandler("/Error");
              app.UseHsts();
          }
  
          app.UseStatusCodePages();
          app.UseHttpsRedirection();
          app.UseStaticFiles();
          app.UseDefaultFiles();
          app.UseCookiePolicy();
  
          app.UseMvc(routes =&gt; {
              routes.MapRoute(
                  name: "default",
                  template: "{controller=Home}/{action=Index}/{id?}"
                  );
          });
  
          seeder.SeedData();
      }
  </code></pre>
  
  <p>And in this class gets the error thrown:</p>
  
  <pre><code>public class DataSeeder {
      #region Fields
      private readonly ApplicationDbContext _context;
      private Random random;
      private ISet&lt;string&gt; _set;
      #endregion
  
      #region Constructor
      public DataSeeder(ApplicationDbContext context) {
          _context = context;
          random = new Random();
          _set = new HashSet&lt;string&gt;();
      }
      #endregion
  
      #region Methods
      public void SeedData() {
          _context.Database.EnsureDeleted();
          if (_context.Database.EnsureCreated()) { //**on this line**
  
              AddCodes();
  
              //reservations
              Reservation r1 = new Reservation(new DateTime(2019, 2, 21), "Robbe van de Vyver", "Kip met rijst en currysaus", true, "");
              _context.Reservations.Add(r1);
  
              _context.SaveChanges();
          }
      }
  
      private void AddCodes() {
          if (_context.Codes.Count() &lt;= 5) {
              char[] characters = "azertyuiopqsdfghjklmwxcvbn,;:=?+-./+~ù%^$*&amp;éè!çà|@#0123456789AZERTYUIOPQSDFGHJKLMWXCVBN".ToArray();
              for (int i = 0; i &lt; 25; i++) {
                  string code = "";
                  for (int j = 0; j &lt; 4; i++) {
                      code += characters[random.Next(0, characters.Length)];
                  }
                  _set.Add(code);
              }
              _context.Codes.AddRange(_set);
              _context.SaveChanges();
          }
      } 
      #endregion
  </code></pre>
  
  <p>but this isn't the only time this exeception gets thrown, it also gets thrown when I try to load a certain page of my application:</p>
  
  <pre><code>public class ChezMoutController : Controller {
  
      private IRatingRepository _ratingRepository;
      private IReservationRepository _reservationRepository;
  
      public ChezMoutController(IRatingRepository ratingRepository, IReservationRepository reservationRepository) {
          _ratingRepository = ratingRepository;
          _reservationRepository = reservationRepository;
      }
      public IActionResult Index() {
          ViewData["foodAverage"] = _ratingRepository.GetAll().Select(r =&gt; r.FoodRating).Average();
          ViewData["atmosphereAverage"] = _ratingRepository.GetAll().Select(r =&gt; r.AtmosphereRating).Average();
          ViewData["reservations"] = _reservationRepository.GetAll();
          ViewData["DatesLeft"] = new List&lt;DateTime&gt;() { };
          return View(_ratingRepository.GetAll());
      }
  }
  </code></pre>
  
  <p>Every time I try to load the view connected to this Index in this controller, the same exepcetion gets thrown right here: </p>
  
  <pre><code>public class RatingRepository : IRatingRepository {
      private readonly ApplicationDbContext _context;
  
      public RatingRepository(ApplicationDbContext context) {
          _context = context;
      }
  
      public void Add(Rating rating) {
          var any = _context.Ratings.Any(r =&gt; r.RatingId == rating.RatingId);
          if (!any) {
              _context.Add(rating);
          }
  
      }
  
      public IEnumerable&lt;Rating&gt; GetAll() {
          return _context.Ratings.ToList(); //**on this line**
      }
  
      public void Remove(Rating rating) {
          var any = _context.Ratings.Any(r =&gt; r.RatingId == rating.RatingId);
          if (any) {
              _context.Remove(rating);
          }
  
      }
  
      public void SaveChanges() {
          _context.SaveChanges();
      }
  }
  </code></pre>
  
  <p>(the interface this class implements:)</p>
  
  <pre><code>    public interface IRatingRepository {
      IEnumerable&lt;Rating&gt; GetAll();
      void Add(Rating rating);
      void Remove(Rating rating);
      void SaveChanges();
  }
  </code></pre>
  
  <p>I think it has something to do with my rating class:</p>
  
  <pre><code>public class Rating {
      #region Fields
      private double _foodRating;
      private double _atmosphereRating;
      #endregion
  
      #region Properties
      public int RatingId { get; set; }
      public double FoodRating {
          get {
              return _foodRating;
          }
          private set {
              if (value &lt; 0.0 || value &gt; 5.0) {
                  throw new ArgumentException("Give a score between 0 and 5 please.");
              }
              _foodRating = value;
          }
      }
      public double AtmosphereRating {
          get {
              return _atmosphereRating;
          }
          private set {
              if (value &lt; 0.0 || value &gt; 5.0) {
                  throw new ArgumentException("Give a score between 0 and 5 please.");
              }
              _atmosphereRating = value;
          }
      }
      public string PersonalMessage { get; set; } //not mandatory
      public string Suggestions { get; set; } //not mandatory 
      #endregion
  
      #region Constructors
      public Rating() {
  
      }
  
      public Rating(double foodRating, double atmosphereRating, string personalMessage = null, string suggestions = null):this() {
          FoodRating = foodRating;
          AtmosphereRating = atmosphereRating;
          PersonalMessage = personalMessage;
          Suggestions = suggestions;
      }
      #endregion
  
  }
  </code></pre>
  
  <p>but I woudln't know what to do to fix this.
  Any help would be appreciated!</p>
  
  <p>ApplicationDbContext:</p>
  
  <pre><code> public class ApplicationDbContext : DbContext {
      public DbSet&lt;Rating&gt; Ratings { get; set; }
      public DbSet&lt;Reservation&gt; Reservations { get; set; }
      public DbSet&lt;string&gt; Codes { get; set; }
  
      public ApplicationDbContext(DbContextOptions&lt;ApplicationDbContext&gt; options) : base(options) { }
  
      protected override void OnModelCreating(ModelBuilder modelBuilder) {
          modelBuilder.ApplyConfiguration(new RatingConfiguration());
          modelBuilder.ApplyConfiguration(new ReservationConfiguration());
      }
  }
  </code></pre>
  
  <p>RatingConfiguartion</p>
  
  <pre><code>public class RatingConfiguration : IEntityTypeConfiguration&lt;Rating&gt; {
      public void Configure(EntityTypeBuilder&lt;Rating&gt; builder) {
          builder.ToTable("Rating");
  
          builder.HasKey(r =&gt; r.RatingId);
  
          builder.Property(r =&gt; r.PersonalMessage)
              .HasMaxLength(250)
              .IsRequired(false);
  
          builder.Property(r =&gt; r.Suggestions)
              .HasMaxLength(250)
              .IsRequired(false);
      }
  }
  </code></pre>