Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

How can database table update with code

$
0
0

Hi,

I addded table on database with model. however, if I change this model, how can I update database with code. I don't want to use this (add-migration "Add initial entity models"  and update-database)

I can create if there isn't database  -> context.Database.EnsureCreated();

my project is asp.net core 2,0

[code]
public void Configure(IApplicationBuilder app, IHostingEnvironment env, PSContext context)
{
if (env.IsDevelopment())
{
app.UseBrowserLink();
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Home/Error");
}

app.UseStaticFiles();

app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});

context.Database.EnsureCreated();

}

[/code]


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>