私はこのチュートリアルに従っています:http://msdn.microsoft.com/en-us/data/jj193542をCode First
使用した基本についてADO.NET EF
。問題は、コードを実行するときにデータベースが自動的に作成されないapp.config
ことです.私のサーバーに接続し、必要に応じて作成されたデータベースを使用するか、チュートリアルのプログラムで、書かれている内容から期待どおりに新しいデータベースを作成します。
これは私の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=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<entityFramework>
<!-- <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="v11.0" />
</parameters>
</defaultConnectionFactory> -->
<connectionStrings>
<add name="BloggingContext"
providerName="System.Data.SqlClient"
connectionString="server=milka-pc\sqlserver2012;Database=Panorama;user id=MyID;password=MyPass;port=3333;Integrated Security=True;"/>
</connectionStrings>
<!--<contexts>
<context type=" Blogging.BloggingContext, MyAssembly">
<databaseInitializer type="Blogging.MyCustomBlogInitializer, MyAssembly" />
</context>
</contexts>-->
</entityFramework>
</configuration>
ご覧のとおり、機能させるためにさまざまなことを試したので、いくつかの部分がコメントされています。
これは、接続しようとしているときにサーバーエクスプローラーがどのように見えるかです。
また、私は ViasualStudioXXXX とデータベースへの接続の経験がまったくないため、これが私が見ているものであり、サーバーを選択する方法です。
そこに、milka-pc\sqlserver2012
私が使用できる名前のDBがありPanorama
ます。または、チュートリアルを順を追って実行し、プログラムを終了して新しいDBを作成します。今のところ、私はこれらの 2 つのどちらもできません。に接続するmilka-pc\sqlserver2012
には、提供する必要がありUserName
、Password
で行いましたApp.config
。これらのフィールドが空白ではないことを知るためにこれを言います