ObjectContext.CreateDatabase () creates additional tables outside of the .edmx model

I have the following code:

HorekoEntities db = new HorekoEntities(Utils.GetDbConnStrByName(db_name));
if (!db.DatabaseExists())
{
    db.CreateDatabase();
}

      

which creates a database with tables from the HorekoEntities model. The problem is that it adds 3 additional tables that are not part of this model. I had these tables in the model, but I removed them from the model and from the database.

In the case of debagging, I don't see these tables in db

, and they are not in db.CreateDatabaseScript()

. (I read somewhere that CreateDatabase()

first calls CreateDatabaseScript()

and then creates the database with this script)

The MSDN documentation describes the method as:

"Creates a database using the current data source connection and metadata in the StoreItemCollection."

I'm trying to figure out what's in StoreItemCollection

, but I can't figure out how to get to it. Maybe StoreItemCollection

somehow caching these 3 tables?

Another thing that might be important is that this problem only happens with the connection string from our server. Locally on my machine this is not the case.

+3


source to share


1 answer


You removed tables from context using the constructor, didn't you? They are still in your SSDL. Open EDMX as text (XML editor), find the table name and remove any reference to that table.



0


source







All Articles