How to create a tablo without primary key in entity? - entity-framework

Entity database model insert project and than create database.But some tables not created.
I added primary key and created it again but the same tables didn't occur with primary key.
So 2 tables(don’t created 2 tables) set a primary key.But I dont solve a problem.
How to solve problem in entity?

Related

Generate one Id column included in composite Primary Keys in JPA, while one Id starts from 1 when the other Id column changes

The entity A has an OneToMany relation with the entity B. I would like to use a composite primary key for the entity B, where one of the columns is the same as the the primary key of the entity A and the second column should be generated. How can the second column be started from 1 whenever the the other involving column within the composite primary key changes?
I use Oracle data bank and could not find any solution.
Thanks in advance!

PostgreSQL oximoron

Hi all,
Can any understand what's going on here?
The case is:
There are 2 tables, called "matricula" and "pagament" with a 1:1 relationship cardinality.
Table matricula primary key composed by 3 fields "edicio","curs" and "estudiant".
Table pagament primary key, the same as above. Furthermore, it references matricula.
As shown, trying to insert a row in pagament table is rejected because it does not exists a row in table matricula. However, asking for this row returns one result.
What am I missing?
Thanks you all
Carles
The problem is that the order of the fields in both tables is not the same, and, moreover, the restriction of the foreign key in table pagament, said that
foreign key (estudiant,curs,edicio) references matricula
without specifying the matricula fields.
It's been solved by setting this restriction as
foreign key (estudiant,curs,edicio) references matricula(estudiant,curs,edicio)

Query which will delete other table reference as well as from main table

I have a requirement of deleting records from the Postgres database tables.
We have a Customer table which is the main table, this table contains a primary key which is used in so many other tables as a FOREIGN KEY, I want to delete one of the customers as well as its reference used in other tables. Is there any way to delete the customer from main table as well as from other tables which contains foreign key.
Thanks in Advance.
In the other tables, you want a cascading delete foreign key reference. You can create one in the database using:
alter table othertable add constraint fk_othertable_customerid
foreign key (customerid) references customers(customerid)
on delete cascade;
Note: This assumes that customerid is the name of the column in both tables and that it is already defined in the other tables.
A cascading foreign key constraint does exactly what you specify. When a row is deleted in the reference table, then all related rows are deleted.
If you already have foreign key constraints on customerid, then drop the existing constraint and add the cascading version.

Entity Framework database first foreign key constraints on Delete

I'm trying to understand On Delete and On Update foreign key functions in Entity Framework.
I have a database first (sqlite) model consisting of two tables:
Control
ID
Name
ControlTypeID
and
ControlType
ID
Name
The foreign key constraints on ControlTypeID are set to "On Delete Set Default" and "On Update Cascade." Default is set to "1" on ControlTypeID
The tables are bound to a datagridview. When I delete a ControlType (say, ID=2) rather than Control.ControlTypeID being set to 1, it is set to null.
Does entity framework not preserve the database foreign key constraint rules when it constructs the entity model?

"Tricking" EF core to use unique key instead of primary key

I have a database at work that has tables without primary keys (Sql Server). It uses a different schema. It has a unique (sometimes compound) key for each table. I cannot modify database in any way. It is a vendor's database.
Is it ok to trick EF into thinking the unique key is the primary key? Will there be any issues with inserting or updating records?
Thanks,
Rick