I am working with EF6
and generating models (database-first) from multiple databases. Some databases have same table names so when model is generated they start conflicting. To solve namespace
problem I went to Model.tt
file properties in Solution Explorer and changed Custom Tool Namespace
However this solved my problem only partially as when generating additional Models duplicate (same table name) .cs
files are still being placed into project directory and same table name entities get overwritten.
How do I set model output directory in EF6? Or solve this some other way?
EDIT: After moving .edmx
to it's own folder I am now getting {"Unable to load the specified metadata resource."}
when accessing metadata on line var objectContext = ((IObjectContextAdapter)this.Ecom).ObjectContext;
Thanks to @CodeCaster
Create physical folder in your project directory
Add it to your project by including in Solution Explorer
Add model in that directory (I copied it over but you could try to just generate new one)
Check in Web.config
/(app.config
) if EF connection string generated has it's metadata set as following (Directory structure is done with .
(dot) not /
(slash)) like following res:///Ecom.Ecom.csdl (from being res:///Ecom.csdl while not in it's own folder).
Hope this saves some time.