当前位置: 首页 > news >正文

企业网站维护的要求包括服装设计工作室

企业网站维护的要求包括,服装设计工作室,网站服务器关闭怎么恢复,东莞网络推广服务平台目录 一、新建.NET 6.0控制台应用并建立数据库连接 二、下载并安装EF程序包 三、自动生成EF模型和上下文 1.Blog类模型 2.Post类模型 3.数据库上下文 四、设计自己的应用 VS2022的.NET6.0、.NET7.0框架下默认支持EF7#xff08;版本号7.0.13#xff09;#xff0c;除…目录 一、新建.NET 6.0控制台应用并建立数据库连接 二、下载并安装EF程序包 三、自动生成EF模型和上下文 1.Blog类模型 2.Post类模型 3.数据库上下文 四、设计自己的应用 VS2022的.NET6.0、.NET7.0框架下默认支持EF7版本号7.0.13除非需要没有必要降低版本使用。  一、新建.NET 6.0控制台应用并建立数据库连接 新建.NET 6.0控制台应用并连接数据库。 ServerDESKTOP-3LV13FS;DatabaseBlogging;Trusted_ConnectionTrue;TrustServerCertificatetrue;integrated securitySSPI; 为避免 (provider: SSL Provider, error: 0 - 证书链是由不受信任的颁发机构颁发的。)增加连接字符串“TrustServerCertificatetrue;”。 二、下载并安装EF程序包 因为版本号很新因此可以通过右侧资源管理器、依赖项、右键、管理NuGet程序包、搜索EF安装如下程序包 也可以按照前文介绍的方法安装程序包。 三、自动生成EF模型和上下文 PM Scaffold-DbContext ServerDESKTOP-3LV13FS;DatabaseBlogging;Trusted_ConnectionTrue;TrustServerCertificatetrue;integrated securitySSPI; Microsoft.EntityFrameworkCore.SqlServer 右侧资源管理器自动生成与映射到了数据库的Blog.cs类的模型、Post.cs类的模型数据库有几个列就自动生成几个类的模型和BloggingContext.cs数据库上下文。此处有两点需要注意第一程序包管理控制台必须没有任何警告但可以有类似如下内容的建议。第二EF模型和上下文是自动生成的倘若右侧的资源管理器里没有自动生成EF模型和上下文那么这一步之前含一定有操作错误的地方修改过后重试。 PM Scaffold-DbContext ServerDESKTOP-3LV13FS;DatabaseBlogging;Trusted_ConnectionTrue;TrustServerCertificatetrue;integrated securitySSPI; Microsoft.EntityFrameworkCore.SqlServer Build started... Build succeeded. To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid2131148. For more guidance on storing connection strings, see http://go.microsoft.com/fwlink/?LinkId723263. 为了保护连接字符串中潜在的敏感信息您应该将其从源代码中移出。您可以使用 Name 语法从配置中读取连接字符串从而避免搭建连接字符串 - 请参阅 https://go.microsoft.com/fwlink/?linkid2131148。有关存储连接字符串的更多指南请参阅 http://go.microsoft.com/fwlink/?LinkId723263。 1.Blog类模型 //Blog类模型 using System; using System.Collections.Generic;namespace _10_9; public partial class Blog {public int BlogId { get; set; }public string Url { get; set; } null!;public virtual ICollectionPost Posts { get; set; } new ListPost(); } 2.Post类模型 //Post类模型 using System; using System.Collections.Generic;namespace _10_9; public partial class Post {public int PostId { get; set; }public int BlogId { get; set; }public string? Content { get; set; }public string? Title { get; set; }public virtual Blog Blog { get; set; } null!; } 3.数据库上下文 //EF实体数据库上下文 using Microsoft.EntityFrameworkCore;namespace _10_9; public partial class BloggingContext : DbContext {public BloggingContext(){}public BloggingContext(DbContextOptionsBloggingContext options): base(options){}public virtual DbSetBlog Blogs { get; set; }public virtual DbSetPost Posts { get; set; }protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) #warning To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid2131148. For more guidance on storing connection strings, see http://go.microsoft.com/fwlink/?LinkId723263. optionsBuilder.UseSqlServer(ServerDESKTOP-3LV13FS;DatabaseBlogging;Trusted_ConnectionTrue;TrustServerCertificatetrue;integrated securitySSPI;);protected override void OnModelCreating(ModelBuilder modelBuilder){modelBuilder.EntityBlog(entity {entity.ToTable(Blog);});modelBuilder.EntityPost(entity {entity.ToTable(Post);entity.HasOne(d d.Blog).WithMany(p p.Posts).HasForeignKey(d d.BlogId);});OnModelCreatingPartial(modelBuilder);}partial void OnModelCreatingPartial(ModelBuilder modelBuilder); } 四、设计自己的应用 现在就开始编写属于你的应用吧通过应用程序给Blog里增加一个新的网址并输出到控制台。 // .NET 6.0通过EF7访问已有数据库的应用 using System; using System.Collections.Generic; using Microsoft.EntityFrameworkCore;namespace _10_9 {class Program{static void Main(string[] args){using var db new BloggingContext();db.Blogs.Add(new Blog { Url http://blogs.msdn.com/adonet });var count db.SaveChanges();Console.WriteLine({0} records saved to database, count);Console.WriteLine();Console.WriteLine(All blogs in database:);foreach (var _blog in db.Blogs){Console.WriteLine( - {0}, _blog.Url);}}} } //运行结果 /* 1 records saved to databaseAll blogs in database:- http://blogs.msdn.com/dotnet- http://blogs.msdn.com/webdev- http://blogs.msdn.com/visualstudio- http://blogs.msdn.com/adonet- http://blogs.msdn.com/adonet- http://blogs.msdn.com/adonetC:\Users\YCZN_MT\Desktop\测试1\10_9\10_9\bin\Debug\net6.0\10_9.exe (进程 25864)已退出代码为 0。 按任意键关闭此窗口. . .*/
http://www.yutouwan.com/news/68209/

相关文章:

  • 好的企业官网建设公司外贸网站 seo
  • 网站开发范围说明书最新房地产新闻
  • 开源网站推广昆山网站优化
  • 网站建设需要ui吗全网是哪些平台
  • 哈尔滨 建网站叮当app制作平台登录
  • 做云购网站株洲房地产信息网
  • 教学网站建设 效益安卓优化大师官方版本下载
  • seo网站排名优化公司宁波seo推广公司排名
  • 网站的成本国家企业公示系统
  • 中核华泰建设有限公司网站槐荫区网站建设
  • 网站开发 定制 多少 钱电子政务与网站建设的经验
  • 中国建设银行贷款官网站网站开发长期合作
  • wordpress地址和站点地址错html5新手做的网页
  • 十大购物网站排名相关文章wordpress
  • 大淘客网站上的推广怎么做wdcp搭建网站教程
  • 网站做用户记录网站优化公司服务
  • 湖北建设执业资格注册中心网站做旅游的网站有哪些
  • 网站开发研究背景傻瓜式建设网站的软件
  • 自助游网站开发分析报告做视频网站要什么软件
  • 做二手房怎找房源网站nginx 防御 wordpress 攻击
  • wordpress怎么开启多站点电商公司的网上设计
  • 手机适配网站百度推广投诉电话
  • 烟台中企动力提供网站建设宜春个人网站建设
  • 莆田网站制作企业面向搜索引擎网站建设
  • 耐克1网站建设的总体目标网站备案 视频
  • 学网站建设与管理有用吗营销型网站建设专家
  • 网站关键词排名seo网站服务器租用报价
  • 建立网站的原因百度ai营销中国行
  • python做网站好吗怎么注册自媒体号挣钱
  • 自己创建网站403wordpress插件授权破解版