Bank without PK, but mapped PK to Entity. Is that a problem?

2

I'm having problems with float fields. Well, this post will deal with another subject, but I thought I could somehow infer that problem. I stopped to think and analyze the matter. This bank belongs to the customer and is very old. If someone tells me, to change, to fix, forget it, it will not be possible. The colleague bigown once said that everything is wrong with the bank. Well, I've seen that the bank does not have PK and all fields are Nullable , but in my Entity Model class, I mapped the IdLiberation field to PK, so I see that is not Identity :

[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
[Column("ID_LIBERACAO")]
public int IdLiberacao { get; set; }

I'm only working with three tables, it may be that in the client itself (I do not have access) PK can exist, I do not know, only in the second I can ask, but the whole point is to solve the problem with float and double fields. Because it is a Nullable field in BD, I thought it might bring some kind of problems, which I do not know if somehow it might be interfering with my behavior system, which opened this post . Everything is badly done in the bank, at least here with me, but like I said, I can not change it. I can even fix mine here by creating the PK's. This bank ( Sql Server 2012 ) runs on a client-developed Clarion system. I'm waiting for some response. The question is: Regarding the previous post, this situation has to do? Can this leave the behavior of Entity giving problems like what I'm facing? Everything spoken here, has to do with the script to create the three tables that have passed me. They did not pass any script to create PK or FK or Index, so I thought that what I have here is a small copy of what exists in the client, but now came doubts. It's hard to believe in a bank without PK. I think they forgot to give me the script. This way, the solution of the problem in another post, is solving, I hope so.

    
asked by anonymous 17.09.2017 / 02:57

1 answer

0

What intrigues me is the fact that the bank does not have PK. If you were given a database script, a big chance of exporting the database to script, you did not have to export the database constraints as well, so you do not have PK, FK, and NULL. Good on questions:

  

The problem is that the bank does not have PK, FK, and NULL, and you make the validation code direct in the code and not have them in the database.

The problem is that the bank remains open to a lot of failure, eg if another application communicates with the same bank, the insertion / deletion constraints you entered will not affect, opening gap for failures. >

  

This can leave the behavior of Entity giving problems like what   Am I facing?

In some cases yes and others do not, the Entity Framework does not have direct control of your database, what happens is you speak to the Entity: "Add this NULL value in the x field" and send it to your bank this information, if your bank does not accept null registration, it will return an exception for breach of integrity.

I've had experience with database first banks where the bank had an FK, and the Entity Framework did not even know that their property was an FK, because they forgot to put a dataannotation [ForeignKey] or a Fluent validating this, and it was not because of that that it did not work.

The best thing to do is to alert your customer about your current state, transparency is everything.

    
18.09.2017 / 01:43