简体   繁体   中英

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.

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.

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM