I realized that the issue was with the schema of the tables that were created by the mobile service. Instead of using the default "dbo" schema, the tables used <mobile_service_name>
as the schema. My MVC project was looking for dbo.<Table_Name>
instead of <mobile_service_name>.<Table_Name>
and was throwing an error as a result. To fix this, you need to add some mappings in you DB Context class to tell it where exactly to find the tables it is looking for. These mappings are done in an overridden method called OnModelCreating
. It ends up looking like 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>");
}
}