We have a .NET Framework 4.8 application that uses Entity Framework 6.
Now we are having a problem that we need to add some tables that don't guarantee any uniqueness (no primary key and rows can duplicate). There is no way to change the tables because it might break things (this table is re-populated 4AM everyday by a program that we can't control).
Pretty much the exact same problem as described in this question, but the answer simply said don't use Entity Framework 6. Another alternative I can think of is to have a view or have another program that imports the data of this table to a new table.
Is there really no Fluent API or Annotation workaround on the Entity Framework side? Do I really need to introduce a whole new way to access our database or introduce a new view just because in EF6 an entity must have a primary key?
Example of the tables' relation (actual table but I've removed most unrelated columns):
class Customer
{
[Key]
public int CustomerID { get; set; }
public string FirstName { get; set; }
public virtual ICollection<CustomerOutboundEvent> CustomerOutboundEvents { get; set; }
}
// The new table
class CustomerOutboundEvent
{
// Adding key that doesn't actually exist will cause this error: Invalid column name 'CustomerOutboundEventID'.
//[Key]
//public int CustomerOutboundEventID { get; set; }
public int CustomerID { get; set; }
public Customer Customer { get; set; }
public string OutboundNumber { get; set; }
public string EventMessage { get; set; }
}
don't use Entity Framework 6yes, if you don't want an ORM, don't use an ORM.eventrows? Wont that result in eg duplicate emails sent to each customer?