When I create a new record of RoomSettings I get:
Microsoft.EntityFrameworkCore.DbUpdateException: An error occurred while saving the entity changes. See the inner exception for details.
MySqlConnector.MySqlException (0x80004005): Field ‘password’ doesn’t have a default value
Here is the model
public class RoomSettings
{
public int Id { get; init; }
public int RoomId { get; init; }
public RoomAccessType AccessType { get; set; }
public string Password { get; set; } = "";
}
Here is how I create
var newRoom = new Room
{
Name = eventParser.Name,
LayoutId = layout.Id,
Layout = layout,
OwnerId = client.Player.Id,
Owner = client.Player,
MaxUsersAllowed = 50,
Description = eventParser.Description,
CreatedAt = DateTime.Now
};
newRoom.Settings = new RoomSettings
{
RoomId = newRoom.Id,
Password = ""
};
newRoom.ChatSettings = new RoomChatSettings
{
RoomId = newRoom.Id
};
newRoom.PaintSettings = new RoomPaintSettings
{
RoomId = newRoom.Id,
};
dbContext.Rooms.Add(newRoom);
roomRepository.AddRoom(newRoom);
client.Player.Rooms.Add(newRoom);
await client.WriteToStreamAsync(new RoomCreatedWriter
{
Id = newRoom.Id,
Name = newRoom.Name
});
await dbContext.SaveChangesAsync();
New contributor
sam korbin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.