需要帮助使用Entity Framework Code First,MVC创建POCO类 [英] Need help in creating POCO classes using Entity Framework Code First, MVC

查看:126
本文介绍了需要帮助使用Entity Framework Code First,MVC创建POCO类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发将由学生,提供商,管理员,代理商等使用的应用程序。我正在数据库中创建一个Users表,其中将存储系统的每个用户(代理,学生,提供商等)的登录信息并且它们各自的字段(如名字,姓氏等)将保存在各自的表中,如学生,提供者等。我将userId作为用户表中的主键保存为其他关系表中的外键。



当学生,提供者等通过注册表注册系统时,数据库将被点击。用户相关数据将存储在Users表中,特定于该实体的其他字段将存储在其各自的表中。



我正在使用具有流畅API的Entity Framework Code First 。请帮我为这些表创建模型类。还有一个兴趣表,其中注册学生可以从下拉列表中的可用兴趣中选择多个兴趣,这将从兴趣表中填写。我想在StudentsInterests表中存储它。帮我为此创建模型类。



谢谢

解决方案

你可以进去以下方式:



- >首先在您的解决方案中添加和实体模型(edmx)



- >将你的桌子添加到那个edmx



- >给桌子提供关系



- >现在您可以通过选择添加代码生成项选项生成POCO类



- >然后您可以从您的模型生成数据库





希望这有帮助



快乐编码...... !!!


在安装此工具后,使用VS addin的EF生产工具或EF Power Tools,借助此工具进行逆向工程。(将自动创建POCO和DbContext)

I am developing application which will be used by Students, Providers, Administrator, Agents, etc. I am creating a Users table in database where login information of each user of the system (Agents,Students,Providers etc) will be stored and their respective fields (like firstname, lastname, etc) will be saved in respective tables like Students, Providers, etc. I am keeping userId which is primary key from users table as foreign key in other tables for relations.

The database will get hit when Student, Provider, etc are registering for the system through registration form. User related data will get stored in Users table and other fields specific to that entity will get store in its respective table.

I am using Entity Framework Code First with fluent API. Please help me to create model classes for these tables. Also there is one Interests table where while registering Student can select multiple Interests from the available interest from dropdown which will get fill from Interests table. I want to store this as well in StudentsInterests table. Help me to create model class for this as well.

Thanks

解决方案

Well you can go in following manner :

->First of all add and entity model (edmx) in your solution

->Add your tables into that edmx

->Give relationships to tables

->Now you can generate POCO classes by selecting option "Add Code Generation Item"

->Then you can Generate Database from your model


Hope this helps

Happy Coding...!!!


Hi use VS addin''s either EF productivity tools or EF Power Tools, after this tool is being installed,make reverse engineering with help of this tools.(POCOs and DbContext will automatically be created)


这篇关于需要帮助使用Entity Framework Code First,MVC创建POCO类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆