Bank without PK, but I checked the PK by the Entity. Is this a problem?

Asked

Viewed 135 times

2

I’m having trouble with fields float. Well, that post will deal with another matter, but I thought I could somehow infer in this problem. I stopped to think and analyze the subject. This is the customer’s bank and it’s very old. If someone tells me to change it, to fix it, forget it, it won’t be possible. Mr Maniero once said that everything is wrong with the bank. Well, I saw that the bank does not have PK and all fields are nullable, but in my Entity Model class, I selected the field IdLiberacao as PK, that way and I see that it’s 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 same client (I have no access) there may be PK, I do not know, only in the second I can ask, but the whole issue is to solve the problem with fields float and double. For being a field nullable in the comic book, I thought that this could bring some kind of problems, problems that I don’t know, if somehow, could be interfering with the behavior of my system, which I opened this post. Everything is badly done in the bank, at least here with me, but as I said, I have no way to change. I can even fix mine here, creating the PK’s. This database (Sql Server 2012) runs with a system developed in Clarion in the client. I am waiting for some answer. The question is: In relation to the previous post, does this situation have to do? Can this leave the behavior of the Entity giving problems like what I’m facing? Everything said here, has to do with the script creation of the three tables passed to me. No script of PK or FK or Index, so I thought what I have here is a small copy of what exists in the customer, but now came doubts. It is hard to believe in a bank without PK. I really think they forgot to pass me the script. Thus, the solution of the problem in another post, It will be solved, so I hope.

  • Was a database DER made? It is very recommended.

  • @Rorschach, like I said, I don’t have access to anything in this bank. My App that I am creating, they passed me the script of the three tables that will be used and nothing else. I don’t work inside the company, I’m 300 miles away from them, so I don’t know much about the bank. I can’t tell you anything in this bank.I created one for myself, added the tables(3) and I see it. Here yes, I can do whatever I want, you know. I’ll create a PK, with Identity and see what happens.

1 answer

0

What puzzles me is the fact that the bank doesn’t have PK. If you were given a database script, a great chance to export the database to script, they did not export the constraints from the database, so you do not have PK, FK and NULL. Good about the doubts:

Problem of the database not having PK, FK and NULL and you do direct in the code this validation and not have them in the database.

The problem is that the bank remains open to much failure, example would be if another application communicates with the same bank, the restrictions of insertions/changes/exclusions that you entered will not affect, opening gap to failures.

This can leave the behavior of the Entity giving problems such as what I am facing?

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

I’ve had experience with banks database first where the bank had an FK, and the Entity Framework didn’t even know that his property was an FK, because they forgot to put a dataannotation [ForeignKey] or a Fluent validating it, and that’s not why it didn’t work.

The best thing to do is to alert your client about your current state, transparency is all.

  • So, the script I received did not have PK, but since it was only three tables, I don’t think there is no PK in the comic book. I’ve worked without FK, it was a file the part that made the FK(text), but without PK, I find it almost impossible. The fact is that I put in my example now PK and already solved the problem I had been having. Today I will hold a meeting with them and I will place several points, among them the question of PK’s and FK’s.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.