Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Copy Entity Model from one project to another in VS2010

how can one copy Entity Framework model (edmx) from one WPF solution to another in VS 2010? Simple Ctrl-C + Ctrl-V doesn't work.

like image 224
Cartesius00 Avatar asked Jun 05 '11 08:06

Cartesius00


2 Answers

Copy it from the folder and place in another. Then using Add >> Existing Items >>

Its wiser to regenerate in the new project in case if there are any other dependencies created elsewhere in application.

like image 196
Faisal Nasim Avatar answered Oct 05 '22 05:10

Faisal Nasim


Looks like you are trying to share EDMX between two solutions, aren't you? In such case isn't it better to have EDMX, context and all entities in the separate assembly and share either compiled assembly or the whole project (add existing project to the second solution)? You can also share the EDMX file itself by Add existing item as a link. Anyway when adding the EDMX file to the second solution you will also need to add its .Designer.cs file (unless you are using T4 templates). For this you will have to edit .csproj file manually (open it as XML). Make sure that your .csproj file contains sections like:

<ItemGroup>
    <Compile Include="Model.Designer.cs">
        <AutoGen>True</AutoGen>
        <DesignTime>True</DesignTime>
        <DependentUpon>Model.edmx</DependentUpon>
    </Compile>
    <!-- other files included in the project -->
</ItemGroup>
<ItemGroup>
    <EntityDeploy Include="Model.edmx">
        <Generator>EntityModelCodeGenerator</Generator>
        <LastGenOutput>Model.Designer.cs</LastGenOutput>
    </EntityDeploy>
 </ItemGroup>
like image 20
Ladislav Mrnka Avatar answered Oct 05 '22 07:10

Ladislav Mrnka