.NET中微软实体框架的数据访问方法 (4)

.NET中微软实体框架的数据访问方法

In an analogous way add a new entity named Class and add a new property named ClassName. We here are trying to create a student and a class relationship where a class can have multiple students. So, we have an option to choose Association from toolbox as shown below and drag the Association tool from Class to Student and it showed 1 to many relationship.

.NET中微软实体框架的数据访问方法

We are not adding more entities and try to understand the basic functionality with these two entities. Right click on the designer and click on "Generate Database from Model…" option to generate the scripts.

.NET中微软实体框架的数据访问方法

Once you click on "Generate Database from Model…" option, you’ll be asked to choose data connection as shown in the following window. You can choose a new connection or an existing one. I’ll choose a new connection but before that, I’ll create an empty database on my SQL server so that I do not have to modify my scripts to provide a database name. By default, the generated scrips create tables in the master database if DB name is not specified.

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wpjzdj.html