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

HasTrigger is not working with synonymous tables #813

Closed
iahmed9312 opened this issue Aug 29, 2023 · 7 comments
Closed

HasTrigger is not working with synonymous tables #813

iahmed9312 opened this issue Aug 29, 2023 · 7 comments

Comments

@iahmed9312
Copy link

After updating to EFCore7 (HasTrigger) is now required before inserting to a table, and thankfully POCO is updated since v3.8.0 . However, I have added table (that has trigger) as synonymous from another database but (HasTrigger ) is not added by POCO.

@sjh37
Copy link
Owner

sjh37 commented Aug 29, 2023

Hi. HasTrigger was added to v3.8.1 and enhanced in v3.8.2.
See release v3.8.2 notes

Please show me the SQL to create the trigger for the table, and the SQL for the table so that I may test it.

@sjh37
Copy link
Owner

sjh37 commented Aug 29, 2023

I also wanted to check you have set Settings.TemplateType = TemplateType.EfCore7 in your .tt settings file.

@iahmed9312
Copy link
Author

Thank you for your reply.

The template is set to Settings.TemplateType = TemplateType.EfCore7

To replicate my situation please follow the steps:

  1. Create new database (Database1)
  2. Create table (Table1)
  3. Create trigger for Table1

If you run POCO in Database1 it will run correctly and it will add (HasTrigger to Table1)

To get to my issue please follow the steps:

  1. Create a new database (Database2)
  2. Create new Synonym pointing to Database1.dbo.Table1

Now if you run POCO on Database2 it will run correctly except it will not add (HasTrigger to Table1)

I hope it is clear.

@iahmed9312
Copy link
Author

Please note you have to change FilterSettings.IncludeSynonyms = true in your .tt settings file

@sjh37
Copy link
Owner

sjh37 commented Sep 7, 2023

Try the attached file. It only works on SQL Server currently. Let me know if it works for you.
EF.Reverse.POCO.v3.zip

@iahmed9312
Copy link
Author

Thank you very much, it is working perfectly!

@sjh37
Copy link
Owner

sjh37 commented Nov 19, 2023

Released in v3.9.0

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

No branches or pull requests

2 participants