Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/261.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 你和路战士。虽然最后一次射门是你,但我认为是道路勇士让我们走上了这条路,所以我会让你们两个都上,但我会接受他的回答。但我还是很高兴见到你!我可以问你,如果我必须为每个项目重复app.config过程吗?因为app.config在项目中,我想其他人将无法看到_C#_Sql_Database - Fatal编程技术网

C# 你和路战士。虽然最后一次射门是你,但我认为是道路勇士让我们走上了这条路,所以我会让你们两个都上,但我会接受他的回答。但我还是很高兴见到你!我可以问你,如果我必须为每个项目重复app.config过程吗?因为app.config在项目中,我想其他人将无法看到

C# 你和路战士。虽然最后一次射门是你,但我认为是道路勇士让我们走上了这条路,所以我会让你们两个都上,但我会接受他的回答。但我还是很高兴见到你!我可以问你,如果我必须为每个项目重复app.config过程吗?因为app.config在项目中,我想其他人将无法看到,c#,sql,database,C#,Sql,Database,你和路战士。虽然最后一次射门是你,但我认为是道路勇士让我们走上了这条路,所以我会让你们两个都上,但我会接受他的回答。但我还是很高兴见到你!我可以问你,如果我必须为每个项目重复app.config过程吗?因为app.config在项目中,我想其他人将无法看到该app.config。你能解释一下吗,我想知道你在那里做了什么。谢谢!正如我在第一次评论中所说,从错误消息中可以清楚地看到这一点。奇怪的是app.config一团糟。我认为,只有你从一开始就重新尝试教程,你才能知道这个问题是否会重演。是的,你


你和路战士。虽然最后一次射门是你,但我认为是道路勇士让我们走上了这条路,所以我会让你们两个都上,但我会接受他的回答。但我还是很高兴见到你!我可以问你,如果我必须为每个项目重复app.config过程吗?因为app.config在项目中,我想其他人将无法看到该app.config。你能解释一下吗,我想知道你在那里做了什么。谢谢!正如我在第一次评论中所说,从错误消息中可以清楚地看到这一点。奇怪的是app.config一团糟。我认为,只有你从一开始就重新尝试教程,你才能知道这个问题是否会重演。是的,你是对的,实际上你告诉过我,但我很难理解。好的,我会再试一次,这是一个简单的步骤,所以不会花太长时间。@Steve,+1完成这个-我必须去拜访家人。
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
namespace CodeFirstNewDatabaseSample
{
    class Program
    {
        static void Main(string[] args)
        {
            using (var db = new BloggingContext())
            {
                // Create and save a new Blog 
                Console.Write("Enter a name for a new Blog: ");
                var name = Console.ReadLine();

                var blog = new Blog { Name = name };
                db.Blogs.Add(blog);
                db.SaveChanges();

                // Display all Blogs from the database 
                var query = from b in db.Blogs
                            orderby b.Name
                            select b;

                Console.WriteLine("All blogs in the database:");
                foreach (var item in query)
                {
                    Console.WriteLine(item.Name);
                }

                Console.WriteLine("Press any key to exit...");
                Console.ReadKey();
            }
        }
    }

    public class Blog
    {
        public int BlogId { get; set; }
        public string Name { get; set; }

        public virtual List<Post> Posts { get; set; }
    }

    public class Post
    {
        public int PostId { get; set; }
        public string Title { get; set; }
        public string Content { get; set; }

        public int BlogId { get; set; }
        public virtual Blog Blog { get; set; }
    }

    public class BloggingContext : DbContext
    {
        public DbSet<Blog> Blogs { get; set; }
        public DbSet<Post> Posts { get; set; }
    }
}
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <connectionStrings>
    <add name="BloggingContextDb" connectionString="Data Source=|DataDirectory|BloggingContext.sdf" providerName="System.Data.SqlServerCe.4.0"/>
  </connectionStrings>
</configuration>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
  </startup>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="mssqllocaldb" />
      </parameters>
    </defaultConnectionFactory>
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    </providers>
  </entityFramework>
</configuration>