Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relationships without "key fields" failing... #1454

Open
DynConcepts opened this issue Apr 3, 2024 · 0 comments
Open

Relationships without "key fields" failing... #1454

DynConcepts opened this issue Apr 3, 2024 · 0 comments

Comments

@DynConcepts
Copy link

[Not sure what the proper terminology is]

`using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using InterfacesAndModels.WorkTracking;
namespace EntityPersistance.WorkTracking;
public class WorkTrackingRepository : IWorkTrackingRepository
{
public WorkTrackingRepository()
{
Name = String.Empty;
}
[Key]
public virtual Guid ID {get; set; }
public virtual string Name {get; set; }
public virtual ICollection Items { get; set; } = new List();
}

public class WorkTrackingItem : IWorkTrackingItem
{
[Key]
public virtual Guid ID {get; set; }
[NotMapped]
IWorkTrackingRepository IWorkTrackingItem.Repository
{
get { return RepositoryEntity; }
set { RepositoryEntity = (WorkTrackingRepository)value; }
}
public virtual required WorkTrackingRepository RepositoryEntity { get; set; }
public virtual int WorkItemNumber { get; set;}
public virtual int CurrentRevisionNumber { get; set;}
[NotMapped]
IEnumerable IWorkTrackingItem.Fields
{
get { return FieldEntities; }
set { FieldEntities = (ICollection)value; }
}
public virtual ICollection FieldEntities { get; set; } = new List();
}

public class WorkTrackingField : IWorkTrackingField
{
[Key]
public virtual Guid ID {get; set; }
public virtual required string Name {get; set; }

public virtual string? PersistedValue { get; set; }
[NotMapped] 
public required object Value {get; set; }

[NotMapped]
IWorkTrackingItem IWorkTrackingField.Item
{
    get { return ItemEntity; }
    set { ItemEntity = (WorkTrackingItem)value; }
}

public virtual required WorkTrackingItem ItemEntity { get; set; }

}
`

Building this and then attempting a BulkSaveChanges, results in an error.. that I have tracked to here...
It is looking for a WorkTrackingFieldID [Guid] field, rather than the actual relationship...

Possible some additional annotation is needed rather than whacking the code?

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant