0
はDBを生成する単純なコードを設計しようとすると、接続文字列で失敗しました:コード
namespace CodeFirstDemo
{
public class Post
{
public int Id { get; set; }
public DateTime DatePublished { get; set; }
public string Title { get; set; }
public string Body { get; set; }
}
public class BlogDbContext : DbContext
{
public DbSet<Post> Posts { get; set; }
}
class Program
{
static void Main(string[] args)
{
}
}
}
のapp.config:
<?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.SqlConnectionFactory, EntityFramework" />
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
<connectionStrings>
<add name ="BlogDbContext" connectionString ="data source=.\SQLEXPRESS; initial catalog=CodeFirstDemo; integrated security==SSPI" providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>
私はenable-migrations
を実行した後、私は得たエラー:
Format of the initialization string does not conform to specification starting at index 57.
接続文字列に問題があると思われます。
<add name ="BlogDbContext" connectionString ="data source=.\SQLEXPRESS; initial catalog=CodeFirstDemo; integrated security==SSPI" providerName="System.Data.SqlClient" />
しかし、正確に何が間違っていますか?
あなたは統合セキュリティの後に==を持っています –