We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Is it something that I'm missing in my configuraiton ?
I want to configure a one-to-one relation with some seed data for a owned type.
I've tried the following but with no success
Following is my code.
public class Beneficiary { public long Id { get; set; } public string Name { get; set; } } public class BeneficiaryInvoice { public string Number { get; set; } public DateTime IssueDate { get; set; } public BeneficiaryInvoice Invoice { get; set; } } void IEntityTypeConfiguration<Beneficiary>.Configure(EntityTypeBuilder<Beneficiary> builder) { builder.HasKey(pk => pk.Id); builder.Property(pk => pk.Id) .UseIdentityColumn() .ValueGeneratedOnAdd(); builder.Property(self => self.Name) .HasMaxLength(512) .IsRequired(); builder .OwnsOne(self => self.Invoice, nav => { nav.ToTable("Invoices"); nav.Property(nav => nav.Number).HasMaxLength(16).IsRequired(); nav.Property(nav => nav.IssueDate).HasDefaultValueSql("getutcdate()"); }) .HasData(new { Id = (long)-1, IssueDate = DateTime.UtcNow, Number = "004" }); builder .Navigation(self => self.Invoice) .IsRequired(); builder.HasData( new Beneficiary { Id = -1, Name = "abc", }); }
The seed entity for entity type 'Beneficiary' cannot be added because no value was provided for the required property 'Name'.
Whic I don't know why it complains about because I clearly set the name property value.
If however I make the name as optional by setting isRequired to false (but it needs to be required)
The seed entity for entity type 'Beneficiary' cannot be added because another seed entity with the key value 'Id:-1' has already been added.
I don't understand what I'm missing.
EF Core version: "5"
Database provider: SqlServer
PackageReferences:
Target: dotnet Core 5
Operating system: Windows
IDE: Visual Studio 2019
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Is it something that I'm missing in my configuraiton ?
I want to configure a one-to-one relation with some seed data for a owned type.
I've tried the following but with no success
Following is my code.
Whic I don't know why it complains about because I clearly set the name property value.
If however I make the name as optional by setting isRequired to false (but it needs to be required)
I don't understand what I'm missing.
EF Core version: "5"
Database provider: SqlServer
PackageReferences:
Target: dotnet Core 5
Operating system: Windows
IDE: Visual Studio 2019
The text was updated successfully, but these errors were encountered: