asp.net - I'm getting a cryptic error connecting a new MVC app to an Azure DB created by mobile services -
like title says, trying connect new mvc 5 app created visual studio 2013 existing database table created , azure mobile service.
i realized issue schema of tables created mobile service. instead of using default "dbo" schema, tables used <mobile_service_name>
schema. mvc project looking dbo.<table_name>
instead of <mobile_service_name>.<table_name>
, throwing error result. fix this, need add mappings in db context class tell find tables looking for. these mappings done in overridden method called onmodelcreating
. ends looking this:
public class applicationdbcontext : identitydbcontext<applicationuser> { public applicationdbcontext() : base("defaultconnection") { } public system.data.entity.dbset<myobject> myobjects { get; set; } protected override void onmodelcreating(system.data.entity.dbmodelbuilder modelbuilder) { base.onmodelcreating(modelbuilder); modelbuilder.entity<myobject>().totable("<mobile_service_name>.<table_name>"); } }
Comments
Post a Comment