c# - Fluent API - One to many - multiple relationship -


Hello I have the following problem that I'm trying to solve using the Fluent API.

I have 2 tables:

Products: ID int | Code nurture (20) | CurrentDetailsID int

Product Details IDAI | ProductID int | Name Navratra (50) .... Now my relationships are a bit weird because: the product can only include a current product description (current DITIDID), each record record cend is added to only one product, but the product There may be many details (for historical reasons) in itself.

With any thought how can I store such difficult types of relationships in a fluent API?

Seb

Define your classes as:

If you want to use the Fluent API The following codes can be used.

  Protected Override Zero OnModelCreating (DbModelbuilder modelBuilder) {modelBuilder.Entity  gtc: media.php}; HasMany (t = & gt; t.ProductDetails) Compulsory with (t => T. product). Islingen (T => T. Product ID); ModelBuilder.Entity & lt; Products & gt; () .HasRequired (t = & gt; t.CurrentProductDetail) .RequiredPrincipal () .Map (m = & gt; m.MapKey ("CurrentProductDetailId")); }   

And this is the result:

enter Image description here

Comments

Post a Comment

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -