Very inexperienced with EF and i read that model files is mainly where the EF migration will find DB items to add/drop on migration. We took a client’s code to work on for a friend and adding new columns has been easy peasy however now i am adding a table and i cannot get it to migrate over. I tried with only a model file for the table. Then i tried with all relevent BE files such as, repository.cs, services.cs, commands.cs, queries.cs, models.cs, data (screen shot to show full file paths).
What am i missing? everything is spelled correctly and i even thought of just manually typing it into the up/down area on the migration and then updating the designer file and snapshot. but got an error.
There are no errors in the Terminal either.
here is the Model file code
using System.ComponentModel.DataAnnotations.Schema;
using ABC.Express.Core.Attributes;
namespace ABC.Express.Domain.Models
{
[Table("builder_preferences")] //follows naming convention of other files
public class BuilderPreferences : BaseEntity
{
public long BuilderId { get; set; }
public long GroupId {get; set;}
public static BuilderPreferences Create(long organizationId, long builderId,
long groupId)
{
return new BuilderPreferences
{
OrganizationId = organizationId, //this is in the BASEENTITY
BuilderId = builderId,
GroupId = groupId
};
}
}
}
>Solution :
Ensure that you have added the BuilderPreferences entity to your DbContext’s DbSet. In your DbContext class, you should have something like this:
public DbSet<BuilderPreferences> BuilderPreferences { get; set; }
