I'm working on a .NET Core c# project. I'm using Entity Framework Core to connect to a database. I already created it before and it worked. Then I changed the datatype of an id column from uint to int and now I can't recreate it.
I used the command
dotnet ef database update 0
so I don't have to drop the column and recreate it.
I get this error:
Since that didn't work, I tried changing it back but now that doesn't work anymore either. I also don't understand what this error message is trying to tell me.
Does anyone know what the problem could be?
Here are the classes:
using System;
namespace CarRental.Classes
{
public class CleaningEmployee : Employee
{
public CleaningEmployee(string firstName, string lastName, string emailAddress, string street, uint number, string town, DateTime birthday, string phone, string phoneMobile, bool isAvailable) : base(firstName, lastName, emailAddress, street, number, town, birthday, phone, phoneMobile, isAvailable)
{
}
public CleaningEmployee()
{
}
}
}
This class inherits from the Employee class:
using System;
namespace CarRental.Classes
{
public class Employee : Person
{
public Employee(string firstName, string lastName, string emailAddress, string street, uint number, string town, DateTime birthday, string phone, string phoneMobile, bool isAvailable) : base(firstName, lastName, emailAddress, street, number, town, birthday, phone, phoneMobile)
{
IsAvailable = isAvailable;
}
public Employee()
{
}
public bool IsAvailable { get; set; }
}
}
And the employee class inherits from the person class:
using System;
namespace CarRental.Classes
{
public abstract class Person
{
protected Person()
{
}
protected Person(string firstName, string lastName, string emailAddress, string street, uint number, string town, DateTime birthday, string phone, string phoneMobile)
{
FirstName = firstName;
LastName = lastName;
EmailAddress = emailAddress;
Street = street;
Number = number;
Town = town;
Birthday = birthday;
Phone = phone;
PhoneMobile = phoneMobile;
}
public uint Id { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string EmailAddress { get; set; }
public string Street { get; set; }
public uint Number { get; set; }
public string Town { get; set; }
public DateTime Birthday { get; set; }
public string Phone { get; set; }
public string PhoneMobile { get; set; }
}
}
Here's the id property that I've changed from uint to int and then back to int again.
I don't know if it has anything to do with the issue but here's the seed method I use:
// Creating cleaningEmployee dummy data
CleaningEmployee cleaningEmployee1 = new CleaningEmployee("Peter", "Hueber", "peter.huerber@carrental.ch",
"hueberstrasse", 3, "Zug", new DateTime(2000, 3, 12), "341 324 234 23 12", "234 423 243 43 43", true);
cleaningEmployee1.Id = 1;
CleaningEmployee cleaningEmployee2 = new CleaningEmployee("Samuel", "Müller", "samuel.müller@carrental.ch",
"müllerstrasse", 3, "Zug", new DateTime(2001, 4, 12), "341 234 234 43 12", "234 234 243 54 43", true);
cleaningEmployee2.Id = 2;
modelBuilder.Entity<CleaningEmployee>().HasData(cleaningEmployee1, cleaningEmployee2);
