c# - How to add new table in context ASP.NET MVC -
please, me. had file imagecontext:
using system; using system.collections.generic; using system.linq; using system.web; using system.data.entity; namespace usergallery.models { public class imagecontext : dbcontext { public dbset<image> images { get; set; } } }
i create new model slide , add string connect in imagecontext. result
... public class imagecontext : dbcontext { public dbset<image> images { get; set; } public dbset<slide> slides { get; set; } } ...
how update database create table slides?
screenshoot database table: enter image description here
if have automatic migrations set should pretty straight forward.
if haven't, need run
enable-migrations –enableautomaticmigrations
perhaps further reading here first though: http://msdn.microsoft.com/en-gb/data/jj554735.aspx
create new migration addition of slides
add-migration "slidemigration"
now update... , should work.
update-database
Comments
Post a Comment