.net - How to change the default database name in a DbContext? -
.net - How to change the default database name in a DbContext? -
i have created project code create db set
public class impaldbcontext : dbcontext { public dbset<datadisplay> impaladb { get; set; } }
and when entity framework create database name =" impalaportal.models.impaldbcontext"
how create alter default databse name in mvc 4 want create short name in 1 word
there's dbcontext
constructor overload receives name of connection string parameter, can give whatever name like, long there's connection string name in web.config file.
you want modify impaldbcontext
have constructor
public class impaldbcontext : dbcontext { public impaldbcontext(string connectionstringname):base(connectionstringname) { } public dbset<datadisplay> impaladb { get; set; } }
or, alter name of default connection string this:
public class impaldbcontext : dbcontext { public impaldbcontext():base("yourconnectionstringname") { } public dbset<datadisplay> impaladb { get; set; } }
if i'm not wrong, later create entityframework alter name of generated database.
.net entity-framework
Comments
Post a Comment