c# - How to properly remove a column from AspNetUsers table that was created during a migration with Package Manager Console? -
i added new table identity's database, , think messed because in aspnetusers table have new column thats foreign key new table , don't want in there. best way remove new column?
this how started off
public class applicationuser : identityuser { ... public virtual superadminhistory superadminhistory { get; set; } }
this class
public class superadminhistory { [databasegenerated(databasegeneratedoption.identity)] public int superadminhistoryid { get; set; } public string superadminidcreator { get; set; } public string createdadminid { get; set; } public string datecreated { get; set; } public string modifiedby { get; set; } public string modifieddate { get; set; } public bool isactive { get; set; } }
and added applicationdbcontext : identitydbcontext
public system.data.entity.dbset<superadminhistory> superadminhistory { get; set; }
i when package manager console , did
add-migration "newtable"
then...
update-database
at first made couple mistakes when trying create new table, wondering if earlier mistakes created foreign key in aspnetusers table.
and new table in database.
when add navigation property, creates relationship , ef add foreign key. if don't want that, do:
[notmapped] public virtual superadminhistory superadminhistory { get; set; }
or add fluent mapping: .ignore(p => p.superadminhistory);
if make change , apply migration should remove field. option rollback prior migration:
update-database -targetmigration:"name_of_migration"
Comments
Post a Comment