zoukankan      html  css  js  c++  java
  • CodeFirst Kevin

    1.第一步,创建实体类。

    namespace MyMusicStore.Entities
    {
        /// <summary>
        /// Song
        /// </summary>
        public class Song
        {
            public int id { get; set; }
            public string name { get; set; }
            public string address { get; set; }
            public string singer { get; set; }
            public string age { get; set; }
            public string type { get; set; }
            public string datatype { get; set; }
            public string length { get; set; }
        }
    }
    

      2.创建Context上下文:

    namespace MyMusicStore.Context
    {
        /// <summary>
        /// Context Class
        /// </summary>
       public class MusicContext:DbContext
        {
           public DbSet<Song> songs { get; set; }
        }
    }
    

      3.设置数据库连接字符串

    <connectionStrings>
        <add name="MusicContext" providerName="System.Data.SqlClient" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=MyMusicStore;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-MyMusicStore.UI-20130227200923.mdf" />
      </connectionStrings>
    

      4.数据库数据初始化

  • 相关阅读:
    swing加载图片
    能有效解决问题的提问方法
    资源在线汇总
    如何赢得别人的尊重
    算法总结
    软件工程概述
    java语言基础汇总
    DEBUG技巧汇总
    web技术发展历程
    java中BufferedImage类的用法
  • 原文地址:https://www.cnblogs.com/kfx2007/p/2935905.html
Copyright © 2011-2022 走看看