Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

MVC template with select list from parent not working?

$
0
0

Hi!

I'm testing RC2 for my project, however can't seem to get default generated edit template work.

I have two models Product and ProductVariant. When trying to edit Variants through the generated code I've got error:

"NullReferenceException: Object reference not set to an instance of an object.

Microsoft.AspNetCore.Mvc.Rendering.MultiSelectList.Eval(Object container, String expression)"

One product has been created, so the list shouldn't be empty. Here are the models:

public class Product
{
public int ProductID { get; set; }
public string ManufacturerCode { get; set; }
public int ManufacturerID { get; set; }
public string Name { get; set; }
public virtual ICollection<ProductVariant> Variants { get; set; }

}

 

public class ProductVariant
{
[Key]
public int ProductVariantID { get; set; }

[ForeignKey("Product")]
public int ProductID { get; set; }

public virtual Product Product { get; set; }
public string Name { get; set; }
public string Color { get; set; }

}

Any help would be appreciated. Thanks!


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>