tags:

views:

15

answers:

1

Hi I started from scrath a new vs 2010 solution. How can I add a preexisting edmx file generated with the vs tool avoiding mess :)? (The cleanest way)

Thanks a lot!!

A: 

I am quite sure that adding the edmx file as an existing Item will work quite well. You will have to add the adequate connectionString in your config file however.

<add name="<EntityContainerName>" connectionString="metadata=res://*/<pathToEDMX>.csdl|res://*/<pathToEDMX>.ssdl|res://*/<pathToEDMX>.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=localhost;Initial Catalog=MyDatabase;Integrated Security=True;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient" />

where pathToEDMX is the path to your edmx file in the project (for exemple Models.Model if you included the Model.edmx file in the Models directory of your project)

You will want to change the database connection string in this mmodel connection string too.

In order for this connecion string to work, the model option "Metadata Artifact Processing" must be set to "Embed in Output Assembly"

Maupertuis