1

Topic: Code First + SQL Triggers

Kind time of days, dear colleagues.
Question such. On usage in SQL-triggers how many is justified at approach CodeFirst (EntityFramework Core)
, At presence of variants which eliminate any interference in SQL the server?

2

Re: Code First + SQL Triggers

Calabonga;
It purely ideology how to write.
The main thing not to mix.
It is possible  to consider as the impotent man and data store. Remaining does center.
It is possible to do an emphasis on  as the guarantor of integrity.
If the trigger without  that generally is not present problems.

3

Re: Code First + SQL Triggers

Petro123;
So it is clear, but the specific question concerning migration interests. Hinders or promotes?

4

Re: Code First + SQL Triggers

Calabonga;
Migrations? You about what?

5

Re: Code First + SQL Triggers

skyANA;
DbMigration... CodeFirst (EntityFramework)... Change  (data schemes)...

6

Re: Code First + SQL Triggers

Calabonga wrote:

Petro123;
So it is clear, but the specific question concerning migration interests. Hinders or promotes?

Hinders).
And my small imho that MS that that changes.
That both directions worked. The basis is primary and AppServer is primary.

7

Re: Code First + SQL Triggers

Calabonga wrote:

the Question such. On usage in SQL-triggers how many is justified at approach CodeFirst (EntityFramework Core)
, At presence of variants which eliminate any interference in SQL the server?

It is not justified absolutely not. What for variants mean, can sound?

8

Re: Code First + SQL Triggers

Calabonga wrote:

So it is clear, but the specific question concerning migration interests. Hinders or promotes?

Not that hinder. But do not promote, it is exact.

9

Re: Code First + SQL Triggers

Calabonga wrote:

skyANA;
DbMigration... CodeFirst (EntityFramework)... Change  (data schemes)...

It depends...
For example we roll out the new version only on a part of servers and we include only parts of users.
And any time it is necessary to write the data to both places: new and old.
Here the trigger helps.

10

Re: Code First + SQL Triggers

skyANA wrote:

Here the trigger helps.

Too the special case, and the HARDWARE yet did not sound the variants of usage.

11

Re: Code First + SQL Triggers

Give I will result a specific example, and for one can that advise. We assume that at me is Computed Description property, I should store in it, $ "{Name} will pay you {Amount} of {CurrencyName}". At change in a DB of any of properties involved in expression, it would be desirable to have "the fresh" version in property Description.
What sentences will be?

12

Re: Code First + SQL Triggers

Calabonga wrote:

Give I will result a specific example, and for one can that advise. We assume that at me is Computed Description property, I should store in it, $ "{Name} will pay you {Amount} of {CurrencyName}". At change in a DB of any of properties involved in expression, it would be desirable to have "the fresh" version in property Description.
What sentences will be?

To do it within the limits of application. Why? At first, today to you it is necessary {Name} which is accessible from writing fields, and tomorrow it is necessary to add there, let us assume, a name of the current user which of the trigger will be inaccessible. Secondly, triggers are heavy for testing. Thirdly, you need one behavior in one surrounding, and another in other (dev, staging, production...).

13

Re: Code First + SQL Triggers

Calabonga;
On EF you Computed Description can be easily implemented by means of property, but it is better, if it is fulfilled at repository level.

14

Re: Code First + SQL Triggers

Calabonga;
Besides. It is all truly until correctly that with a database application works only, and anybody pens in basis does not climb. If it so me here to advise something is difficult. Triggers, certainly look as the decision, but from personal experience, it not so.

15

Re: Code First + SQL Triggers

hVostt wrote:

Calabonga;
Besides. It is all truly until correctly that with a database application works only, and anybody pens in basis does not climb. If it so me here to advise something is difficult. Triggers, certainly look as the decision, but from personal experience, it not so.

That's just the point, also it is possible to do without the trigger. While one application (or some applications) works, but they work by one rules, that is the same function of formation Description it is all everywhere is used works. But as soon as "pens", someone will correct in a DB the trigger fulfills, and without it Description will be broken"

16

Re: Code First + SQL Triggers

Calabonga wrote:

But as soon as "pens", someone will correct in a DB,

.
the enterprises it not your property.
Or do big AppServer and all walk through it, or...

17

Re: Code First + SQL Triggers

Petro123;
I understood, thanks all. In general, you confirmed my assumptions.

18

Re: Code First + SQL Triggers

Calabonga wrote:

That's just the point, also it is possible to do without the trigger. While one application (or some applications) works, but they work by one rules, that is the same function of formation Description it is all everywhere is used works. But as soon as "pens", someone will correct in a DB the trigger fulfills, and without it Description will be broken"

Therefore with basis one application should work, and others to work dataful through it. It is called three-zvenka .

19

Re: Code First + SQL Triggers

hVostt wrote:

it is passed...
Therefore with basis one application should work, and others to work dataful through it. It is called three-zvenka .

In other words, it BLL should be implemented separately from a DB through any abstraction layer, for example through pattern Repository. So?

20

Re: Code First + SQL Triggers

Calabonga wrote:

pattern Repository

was gave to you this pattern.
People not loving  invented for a long time a word   words the trigger.
Well, still sometimes , , .
So DbInterception should arrange you.
On good it is necessary to be able to write and and so.

21

Re: Code First + SQL Triggers

Calabonga wrote:

it BLL should be implemented

in a service layer

22

Re: Code First + SQL Triggers

Petro123;
The strange comment, and especially about "to write and and so". To what it? To write with usage of the ancient approach (two-zvenka) and more advanced (three-zvenka)... And what for to write in an old fashion? What profit from it?
And about people who do not love a DB, at all did not understand. Such "inventing" , and a pattern one and what  as they it name?, In my opinion, that people understood the main thing that tell them . And as you pattern Repository will name - already a grand piano does not play.

23

Re: Code First + SQL Triggers

Calabonga;
You were going to rivet sites or a bloody enterprise?
Here, in bloody, it is necessary to know triggers, , normalization, ...
Though is finite we in a branch of three .
So about second-hand articles you in vain.
Tools grow old, and the architecture is few.
About a pattern did not understand. To name them on another it is impossible. Their names it is the dictionary and constants. It to cram.

24

Re: Code First + SQL Triggers

Calabonga wrote:

it is passed...
In other words, it BLL should be implemented separately from a DB through any abstraction layer, for example through pattern Repository. So?

Aha, it is the typical approach.
[img=https://1.bp.blogspot.com/-gnOa4RZNxBI/U8KbC8qcAoI/AAAAAAAABdU/JqNLODkXeNg/s1600/%D0%A2%D0%B8%D0%BF%D0%BE%D0%B2%D0%BE%D0%B9+%D0%B4%D0%B8%D0%B7%D0%B0%D0%B9%D0%BD.png]
And still is CQRS from one DB and without Event Sourcing:-Q

25

Re: Code First + SQL Triggers

Calabonga;
Or it is short on a subject - triggers it not second-hand articles! Even if appeared .)
?