c# - How to remove database columns from default asp.net mvc application? -
i trying learn asp.net , hence want create project using default project in visual studio > asp.net project > mvc project. customize in bits , try learn asp.net.
i ran , registered user , able open database explorer. here there many columns "emailconfirmed" , "twofactorauth" etc did not need, wanted delete them. deleted them database(localdb), keep getting errors invalid column name "emailconfirmed" etc. how make sure totally gone project good. believe there in c# code somewhere, don't know in file.
and have extremely important question, silly question. code in default project tells whenever submit form, data should go corresponding database columns? mean code says stuff sqlconnection conn = new sqlconnection(connectionstring)
etc.
just leave columns. if don't want use them, don't. there's no reason delete them. .net identity takes care of database calls. way you're going see db calls , rid of columns implement own userstore or create own authentication system.
to second question:
you should add new fields /models/identitymodels.cs
this:
public class applicationuser : identityuser { public string gender { get; set; } public async task<claimsidentity> generateuseridentityasync(usermanager<applicationuser> manager) { var useridentity = await manager.createidentityasync(this, defaultauthenticationtypes.applicationcookie); return useridentity; } }
from there need create new migration push change database. shouldn't modify database schema (columns , tables) directly, should code first
Comments
Post a Comment