Comments (4)
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.
I've never seen this behavior before. Can you provide a small sample solution where you see the problem occur?
from efdesigner.
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;
- Open the solution with Visual Studio 2022 (latest with .Net 7 SDK you'll likely need).
- Navigate to the Versona.EF project
- Double click on file Models\VersonaModel.efmodel
- Right click on background and click "Generate Code".
- 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).
from efdesigner.
Was the repro helpful?
from efdesigner.
Related Issues (20)
- Cant set inherited entity HOT 1
- No way to import HOT 2
- Missing ForaignKey on 1 <-> 0..1
- How add /drag an existing model or entity to design surface HOT 1
- How to import model/tables From existing Database HOT 2
- INotifyPropertyChanged removed - Help needed HOT 1
- Toolbox Items missing/Greyed out HOT 4
- Null Reference exception in Solution Explorer context menu
- Code Generation Creating Ambiguous Constructor Signatures in Specific Inheritance Scenario
- Meaningless error when trying to drag-and-drop a dll file on diagram area
- Support for per-entity inheritance hierarchy types
- Many to many with EF core 7 HOT 1
- Upgrade entity framework visual editor to latest version, now EF Model Diagrams disabled HOT 2
- Add an Example for ModelElementExtensions.GetAll(T) Method
- Missing INotifyPropertyChanged option on entity HOT 1
- "Save as image" needs work HOT 2
- "Is Identity" field missing from properties view HOT 3
- Auto include flag on connections not working
- I can't open my schema anymore with the latest version of visual studio 2022 17.7.4. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from efdesigner.