3

私は完全に迷っています。MvcMusicStore .Net アプリ ( http://mvcmusicstore.codeplex.com/ ) を MySQL でセットアップしようとしていますが、プロジェクトをコンパイルするときにいくつかのエラーが発生しました。

MySQL での .Net Entity Framework の使用に関するhttp://dev.mysql.comのドキュメントを読みましたが、私は EF の初心者であり、これらは成功せずに行った手順です。

  • MySQL Server 5.5 を既にインストールしています

  • http://mvcmusicstore.codeplex.com/downloads/get/238258で MvcMusicStore をダウンロード

  • MySQL Connector Net 6.4.4 をインストールし、mysql に db を作成しました: CREATE DATABASE mvcmusicstore/*!40100 CHARACTER SET utf8 COLLATE utf8_general_ci */;

  • プロジェクト MvcMusicStore への次の参照を追加しました: mysql.data、(mysql.data.cf が追加されていないか、エラーが発生する)、mysql.data.entity、mysql.web (各ライブラリのプロパティで、「true」を選択) binフォルダーにdllをコピーします)

  • 「web.config」で置き換えられました:

    <connectionStrings>
    <add name="MusicStoreEntities"
    connectionString="Data Source=|DataDirectory|MvcMusicStore.sdf"
    providerName="System.Data.SqlServerCe.4.0"/>
    </connectionStrings>
    

と:

    <connectionStrings>
    <add name="MusicStoreEntities"
    connectionString="Server=127.0.0.1; Database=mvc_store; Uid=root; Pwd={* my password *};"
    providerName="MySQL Data Provider" />
    </connectionStrings>
    <system.data>
    <DbProviderFactories>
    <add name="MySQL Data Provider"
    invariant="MySql.Data.MySqlClient"
    description=".Net Framework Data Provider for MySQL"
    type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.4.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
    </DbProviderFactories>
    </system.data>
  • クリーンなプロジェクト -> コンパイル & 再コンパイルすると、エラーが発生しました:

「system.data の構成セクション ハンドラーの作成中にエラーが発生しました: 列 'InvariantName' は一意に制限されています。値 'MySql.Data.MySqlClient' は既に存在します。」

そのため、「dbproviderfactories」セクションを、MySql および Entity Framework 4.1 コードを最初に使用する方法にあるコードに置き換えました。

    <DbProviderFactories>
    <remove invariant="MySql.Data.MySqlClient" />
    <add name="MySQL Data Provider" 
    invariant="MySql.Data.MySqlClient" 
    description=".Net Framework Data Provider for MySQL"
    type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.4.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
    </DbProviderFactories>
  • 再コンパイルすると、「データプロバイダーが見つかりません」というエラーが発生しました。

    Details: 
    ArgumentException: Can not find the data provider. Net Framework required. It may not be installed.
    
    Error in the source code: 
    
    Row 17:         ' the albums with the highest count
    Row 18: 
    Row 19:         Return storeDB.Albums.OrderByDescending(Function(a) a.OrderDetails.Count()).Take(count).ToList()
    Row 20:     End Function
    Row 21: End Class
    
    File: C:\{...}\MvcMusicStore-Completed\MvcMusicStore\Controllers\HomeController.vb    Row: 19 
    
    stack: 
    
    [ArgumentException: Can not find the data provider. Net Framework required. It may not be installed.]
    System.Data.Common.DbProviderFactories.GetFactory(String providerInvariantName) +1420503
    System.Data.Entity.Internal.LazyInternalConnection.TryInitializeFromAppConfig(String name) +393
    System.Data.Entity.Internal.LazyInternalConnection.Initialize() +47
    System.Data.Entity.Internal.LazyInternalConnection.get_ConnectionHasModel() +9
    System.Data.Entity.Internal.LazyInternalContext.InitializeContext() +262
    System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType) +18
    System.Data.Entity.Internal.Linq.InternalSet`1.Initialize() +63
    System.Data.Entity.Internal.Linq.InternalSet`1.get_InternalContext() +15
    System.Data.Entity.Infrastructure.DbQuery`1.System.Linq.IQueryable.get_Provider() +37
    System.Linq.Queryable.OrderByDescending(IQueryable`1 source, Expression`1 keySelector) +66
    MvcMusicStore.HomeController.GetTopSellingAlbums(Int32 count) in C:\Users\Max\Desktop\Projects\MvcStore\MvcMusicStore-Completed\MvcMusicStore\Controllers\HomeController.vb:19
    MvcMusicStore.HomeController.Index() in C:\Users\Max\Desktop\Projects\MvcStore\MvcMusicStore-Completed\MvcMusicStore\Controllers\HomeController.vb:10
    lambda_method(Closure , ControllerBase , Object[] ) +96
    System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +17
    System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +208
    System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +27
    System.Web.Mvc.<>c__DisplayClass15.<InvokeActionMethodWithFilters>b__12() +55
    System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +263
    System.Web.Mvc.<>c__DisplayClass17.<InvokeActionMethodWithFilters>b__14() +19
    System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +191
    System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +343
    System.Web.Mvc.Controller.ExecuteCore() +116
    System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +97
    System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +10
    System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +37
    System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +21
    System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) +12
    System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
    System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +50
    System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(Action f) +7
    System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action) +22
    System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +60
    System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
    System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8970061
    System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184
    --------------------------------------------------------------------------------
    Microsoft .NET Framework:4.0.30319; ASP.NET:4.0.30319.272 
    

それを解決するために何をすべきかわかりません。

前もって感謝します、

マックス

4

1 に答える 1

0

プロジェクトに MySQL コネクタへの参照を追加したことを覚えていますか?

于 2012-10-19T17:36:32.757 に答える