Create an Entity Data Model (EF basic Series 5) and an entity ef

Source: Internet
Author: User

Create an Entity Data Model (EF basic Series 5) and an entity ef

Now I want to create an object data model for the database (SchoolDB) given at the end of the above section;

The script for the SchoolDB database has been written as follows:

USE masterGO if exists (SELECT * FROM sys. sysdatabases WHERE name = 'schooldb') drop database SchoolDB; go create database SchoolDBGO USE SchoolDB; GO -- CREATE Standard table if exists (SELECT * FROM sysobjects WHERE name = 'standard ') drop table [Standard]; go create table [Standard] (StandardID int primary key, StandardName NVARCHAR (50), [Description] NVARCHAR (250 )); GO -- CREATE a Student table if exists (SELECT * FROM sysobjects WHERE name = 'student ') drop table Student; go create table Student (StudentID int primary key, StudentName NVARCHAR (100) not null, StandardID int references [Standard] (StandardID), [RowVersion] NVARCHAR (50 )); GO -- CREATE StudentAddress table if exists (SELECT * FROM sysobjects WHERE name = 'studentaddress') drop table StudentAddress; go create table StudentAddress (StudentID int primary key, Address1 NVARCHAR (100 ), address2 NVARCHAR (100), City NVARCHAR (100), [State] NVARCHAR (100), CONSTRAINT StudentID_FK foreign key (StudentID) REFERENCES dbo. student (StudentID); GO -- CREATE a Teacher table if exists (SELECT * FROM sysobjects WHERE name = 'teacher') drop table Teacher; go create table Teacher (TeacherID int primary key, teacherName NVARCHAR (50), StandardID int references [Standard] (StandardID), TeacherType NVARCHAR (100 )); GO -- CREATE Course table if exists (SELECT * FROM sysobjects WHERE name = 'Course') drop table Course; go create table Course (CourseID int primary key, CourseName NVARCHAR (50 ), location NVARCHAR (500), TeacherID int references dbo. teacher (TeacherID); GO -- create the StudentCourse table if exists (SELECT * FROM sysobjects WHERE name = 'studentcourse') drop table StudentCourse; go create table StudentCourse (StudentID int references Student (StudentID), CourseID int references dbo. course (CourseID), CONSTRAINT StudentID_CourseID primary key (StudentID, CourseID),); GO

 

First, open the project created in the previous section, select "project name", right-click and select "attribute", and make sure that the. NET framework version used is 4.5;

Next, create an object data model: select the Project name:

 

 

Now let's open the EDMX file using the XML Compiler:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.