I have an ASP.NET MVC3 application that I have built and it has two databases.
One is in reference to the Default Membership Provider and was automatically created when I built the app.
The other is a database I have named SchoolContext and I would like all the information within SchoolContext
to be stored in the same database as all the data in Default Membership Provider.
Here are my two connection strings:
<add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient" />
<add name="SchoolContext" connectionString="Data Source=|DataDirectory|School.sdf" providerName="System.Data.SqlServerCe.4.0" />
I tried renaming ApplicationServices
to SchoolContext
and then commenting out my second connection string and I can load up and "log in" using the default membership provider just fine, but whenever I need to queue the database for information that was stored within the original SchoolContext
, I get errors stating that the model is nonexistant, etc. . . and the data is not built within the database that contains the information from the default membership provider.
I am using an initializer to rebuild the database if the model changes:
public class SchoolInitializer : DropCreateDatabaseIfModelChanges<SchoolContext>
And this works fine any time I edit something in the model and I am using the two database scheme. However, it is not working when I want to join the two databases into one.
I apparently do not know how to connect the two databases as what I am trying to do is not working, how should I appropriately set up mvc to put my SchoolContext
into the same database as the information needed for the Default Membership Provider?