Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EF6: Document workaround to use EDMX files with EF 6.3 on .NET Core #1748

Open
divega opened this issue Sep 18, 2019 · 2 comments
Open

EF6: Document workaround to use EDMX files with EF 6.3 on .NET Core #1748

divega opened this issue Sep 18, 2019 · 2 comments
Assignees
Milestone

Comments

@divega
Copy link

@divega divega commented Sep 18, 2019

I think we should also consider moving the code sample to this repo (currently it is in my personal GitHub account) and update the aka.ms link.

From the preview 9 blog post:

How to work with EDMX files in .NET Core projects

On the tooling side, we plan to release an updated EF6 designer in an upcoming update of Visual Studio 2019 which will work with projects that target .NET Core (tracked in issue #883). Until this new version of the designer is available, we recommend that you work with your EDMX files inside projects that target .NET Framework. You can then add the EDMX file and the generated classes for the entities and the DbContext as linked files to a .NET Core 3.0 or .NET Standard 2.1 project in the same solution. For example, the project file for the .NET Core project can include the linked files like this:

  <ItemGroup>
    <EntityDeploy Include="..\EdmxDesignHost\Entities.edmx" Link="Model\Entities.edmx" />
    <Compile Include="..\EdmxDesignHost\Entities.Context.cs" Link="Model\Entities.Context.cs" />
    <Compile Include="..\EdmxDesignHost\Thing.cs" Link="Model\Thing.cs" />
    <Compile Include="..\EdmxDesignHost\Person.cs" Link="Model\Person.cs" />
  </ItemGroup>
Note that the EDMX file is linked with the 

EntityDeploy build action. This is a special MSBuild task (now included in the EF 6.3 package) that takes care of adding the EF model into the target assembly as embedded resources (or copying it as files in the output folder, depending on the setting on the Metadata Artifact Processing setting in the EDMX). For more details on how to get this set up, see our EDMX .NET Core sample. You can choose to copy the files instead of linking them, but keep in mind that due to a bug in current builds of Visual Studio, copying the files from the .NET Framework project to the .NET Core project within Solution Explorer may cause hangs, so it is better to copy the files from the command line.

@divega

This comment has been minimized.

Copy link
Author

@divega divega commented Sep 18, 2019

@Flem100

This comment has been minimized.

Copy link

@Flem100 Flem100 commented Dec 9, 2019

Thank you for the sample. It took me a while to figure out that I ofc have to change the namespaces of the generated files when I try to do the process in my own project. Also, if I change anything in the edmx, everything will be regenerated on save and all the namespaces will go back to the EF6 project. Is there a way to change the default namespace for the generated files or is there some kind of workaround I should know about?

@ajcvickers ajcvickers assigned ajcvickers and unassigned bricelam Jan 15, 2020
@ajcvickers ajcvickers modified the milestones: 3.1.0, 5.0.0 Jan 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.