Adding Model to Database

Topics: Writing modules
Oct 18, 2011 at 9:15 AM

Hi, Orchard Team.

I try to add an object of model ProductPart that has two fields: UserID and ProductID to the database.

I try to do this code and get an InvalidCastException:

using Orchard.ContentManagement;

//cut

ProductPart product = Services.ContentManager.New<ProductPart>("ProductItem");

product.UserID = x;

product.ProductID = y;

Services.ContentManager.Create(product);

Mirations.cs:

ContentDefinitionManager.AlterTypeDefinition("ProductItem",

cfg => cfg

.WithPart("CommonPart")

.WithPart("ProductPart")

);

Coordinator
Oct 18, 2011 at 6:47 PM

where?

Oct 18, 2011 at 11:05 PM

Oh, I've already solved the problem. It was the driver absence.