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

Compiler Errors After Upgrade to v4.2.3.5 #61

Closed
ab-tools opened this issue Apr 1, 2023 · 6 comments
Closed

Compiler Errors After Upgrade to v4.2.3.5 #61

ab-tools opened this issue Apr 1, 2023 · 6 comments
Labels
question Requesting information

Comments

@ab-tools
Copy link

ab-tools commented Apr 1, 2023

Hello Michael,

thanks for your continuous efforts on this project!

As I was curious to try your fixes for my reported issues #54 and #55, I've just updated from v4.2.1.3 to v4.2.3.5, but looks like this is making things much worse for me unfortunately...

Even following very simple test model generates broken code for me now:
ConfigModel-Test.zip

grafik

This was working without problems in v4.2.1.3.

@msawczyn msawczyn added the question Requesting information label Apr 1, 2023
@msawczyn
Copy link
Owner

msawczyn commented Apr 1, 2023

Not sure where you got the ConfigModel.tt file from, but it wasn't the one added to your project when you added the model. The .efmodel file has some differences that look suspicious as well.

Is this a copy of an old model and .tt that was edited? The model should work fine, but the T4 won't.

@ab-tools
Copy link
Author

ab-tools commented Apr 1, 2023

First thanks a lot for your quick reply, Michael, much appreciated!

I remember that a while ago you asked to do minor manual changes in this file, like removing these two lines:

#><#@ include file="EF6Designer.ttinclude" once="true"
#><#@ include file="EFCoreDesigner.ttinclude" once="true"

And changing #><#@ assembly name="EnvDTE" to #><#@ assembly name="Microsoft.VisualStudio.Interop".

But apart from that it should still be the same file created many years back.
I'm using your tool for a pretty long time, so just updating to newer versions when they become available.

What would you suggest to do?
Can I reset the .tt file to default while keeping the model in the designer intact?

@msawczyn
Copy link
Owner

msawczyn commented Apr 2, 2023

Can I reset the .tt file to default while keeping the model in the designer intact?

Yes. Create a new .tt file and change its name. Do a slight edit to change the name of the model file to the one you're using.

Example:
#><#@ EFModel processor="EFModelDirectiveProcessor" requires="FileName='EFModel1.efmodel'"

That should get you back on track. Normally you wouldn't need to do this, but the change you made was only meant to be a temporary change to get you over the problem you were experiencing earlier.

@ab-tools
Copy link
Author

ab-tools commented Apr 2, 2023

Thanks, Michael, done that now and reset the .tt file by creating a new model, renaming the file and changing the model file name within it manually thereafter - that worked and I can still generate the code.

However, the compilation errors in the generated code persist.

It is this line which was
.UsingEntity(x => x.ToTable("Group_x_User"));
with the old version and worked fine.

Now it is
.UsingEntity<Dictionary<string, object>>(right => right.HasOne<global::Api.Data.Config.User>().WithMany().HasForeignKey(UserId).OnDelete(DeleteBehavior.Cascade),left => left.HasOne<global::Api.Data.Config.Group>().WithMany().HasForeignKey(GroupId).OnDelete(DeleteBehavior.Cascade),join => join.ToTable("Group_x_User"));
and throws the compilation exceptions shown above.

What's the best way to get the models (I have two in production with similar issues) working again?

@msawczyn
Copy link
Owner

It sounds like there's a mismatch between the entity framework core version you're compiling with and the one you've told the model you're using. Can you check that?

@msawczyn
Copy link
Owner

Closing due to lack of activity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Requesting information
Projects
None yet
Development

No branches or pull requests

2 participants