Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

EF migration not creating table

enter image description here

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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; }
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading