Giter Site home page Giter Site logo

Comments (4)

Relki avatar Relki commented on June 10, 2024

Also, when I use dotnet ef migrations add InitialCreate to create migrations, it creates a folder called "Migrations" in the root of the EF project. But when I click save on the efModel, just like the partial classes, it goes through and deletes the migration and snapshot files that dotnet ef creates.

It seems like the generating code walks through and just deletes any code files in any folders. I just tried today to move the model efmodel file and model.tt file into a sub folder instead of the root folder, and then tried same process again. Still deletes any partial classes I create and any migrations created.

Is there a recommended way to create migrations with this designer extensions? I haven't found anything in the Wiki talking to this.

Next I'm going to just tell dotnet ef to generate migration files in the root folder of EF. Maybe then the generated designer code will ignore them.

This designer seems to make using migrations not possible with default documentation from Microsoft. Going to try pointing to root folder today and will have to accept that as a work around for now if it works.

from efdesigner.

msawczyn avatar msawczyn commented on June 10, 2024

I've never seen this behavior before. Can you provide a small sample solution where you see the problem occur?

from efdesigner.

Relki avatar Relki commented on June 10, 2024

I've pulled the Entity Framework projects out of my solution, built a separate solution with my Entity Framework project set up that reproduces this issue.

Note, this project is using .Net 7.0 now. It was using .Net 6.0 and the issue reproduced with that framework as well.

When you open the solution, take note that I have put the partial classes in the same folder as the other Entities.
Example;

Versona.EF\Models\TableEntities\Account.cs
Versona.EF\Models\TableEntities\Account.ShouldSerialize.cs

Account.cs is auto generated, but Account.ShouldSerialize.cs is my partial class implementation. There are several other entities in the same folder with the same naming format.

Also, same pattern with the DbContext;

Versona.EF\Models\Contexts\VersonaModelContext.cs
Versona.EF\Models\Contexts\VersonaModelContext.Implemented.cs

Now, to reproduce the issue;

  1. Open the solution with Visual Studio 2022 (latest with .Net 7 SDK you'll likely need).
  2. Navigate to the Versona.EF project
  3. Double click on file Models\VersonaModel.efmodel
  4. Right click on background and click "Generate Code".
  5. You'll notice that every single partial class will be deleted from the project (Under Models\Contexts and Models\TableEntities).

The only way I could prevent this from happening, was to move all those partial classes, to the root project level. Then they don't get deleted whenever code is generated.

Now, as a note, I did try creating a new project and adding Visual Entity Framework to it again, created a simple Entity with 1 table, and then created a partial class for that same table in the same folder as the auto generated code. When I generated code, it did not delete the partial classes.

So, I could not reproduce this with a brand new project with just 1 table entity. But it does reproduce in my larger project with many entities. I have two such projects, with many entities (Account.EF and Versona.EF). Both larger projects have the exact same issue reproduced.

I had the same problem as well if I created a folder in Versona.EF project called "Migrations". I use to have all my migrations under that folder. However, when the code was generated, it also deleted all the migration class files as well. Imagine my surprise. I had to either move my migration files to the root folder or move them to a separate project (which I ended up doing).

DemoRepro.zip

from efdesigner.

Relki avatar Relki commented on June 10, 2024

Was the repro helpful?

from efdesigner.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.