开发者

MVC3 & EF Code First, Enterprise Unfriendly

Ok, back with not necessarily a true definition of a question but need some advice on starting a new project. I've got an old database that I base most of my projects from (borrowed architecture from previous projects) and it has made life very easy when starting a project. The basic architecture is shown below:

InventoryItem.ID (guid)
InventoryItem.Name (string)

InventoryCategory.ID (guid)
InventoryCategory.Name (string)

RelatedCategory.ID (guid)
RelatedCategory.ParentID (guid)
RelatedCategory.CategoryID (guid)

Now, I wanted to use MVC3 and RAZR for this project but do not see an easy way to do this. It seems as though the examples and blog posts that you read around the web for MVC are simple not enterprise-level examples that basically show a list and show how quick and easy it is for Code-First to generate a database for you that displays a list of items (same as a good ole datasource and datagrid did 7 years ago). That being said, if it's going to be just as difficult to create these views and editors, why not go with traditional web forms?

Also, to push my point even further, I created a class like the following and it didn't create the database as I intended either:

public class Item
{
    public int ID { get; set; }

    [Required(ErrorMessage = "A Name Is Required")]
    public string Name { get; set; }

    public string Description { get; set; }

    public List<RelatedCategory> Categories { ge开发者_StackOverflow中文版t; set; }

    public DateTime CreateDate { get; set; }
}

It did not create the database the way I intended. In-other-words, following my architecture in the database. So, would you guys just not recommend using Code-First or would you use MVC at all for something like this? And if so, can you give an example of how to create a templated editor that will allow me to add multiple categories to an item?


As I said in a comment above. Didn't want to answer my question from my question but the answer I was looking for deals with virtual properties. A great answer is on this post:

How do you actually perform relationships in Entity Framework 4 Code-First CTP 5?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜