Microsoft has been making continuous efforts in cross-platform in recent years, and many .net programmers are gearing up and have high hopes for Microsoft. Just recently, Microsoft also launched a preview version of asp .net core2.0.
Through a simple experiment with .net core, I found that when we developed MVC projects in the past, we generated and updated entities## by creating a new .edmx file. #Model, but in core, Microsoft has removed .edmx, so let me talk about how to generate the model class in core.
Environment: vs2017 + sqlserver2012
CREATE DATABASE [Blogging];GOUSE [Blogging];GOCREATE TABLE [Blog] ( [BlogId] int NOT NULL IDENTITY, [Url] nvarchar(max) NOT NULL, CONSTRAINT [PK_Blog] PRIMARY KEY ([BlogId]) );GOCREATE TABLE [Post] ( [PostId] int NOT NULL IDENTITY, [BlogId] int NOT NULL, [Content] nvarchar(max), [Title] nvarchar(max), CONSTRAINT [PK_Post] PRIMARY KEY ([PostId]), CONSTRAINT [FK_Post_Blog_BlogId] FOREIGN KEY ([BlogId]) REFERENCES [Blog] ([BlogId]) ON DELETE CASCADE);GOINSERT INTO [Blog] (Url) VALUES('http://blogs.msdn.com/dotnet'), ('http://blogs.msdn.com/webdev'), ('http://blogs.msdn.com/visualstudio')GO
略
The above is the detailed content of .net core generates entity classes based on database. For more information, please follow other related articles on the PHP Chinese website!