2014-09-16 2 views
1

У меня есть библиотека классов. в рамках этого проекта у меня есть папка с именем «модели» с несколькими классами. У меня есть все ссылки, которые мне нужны.не удалось создать базу данных сущности сущности в библиотеке классов

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> 
    <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> 
    <connectionStrings> 
    <add name="DefaultConnection2" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=MDD;AttachDbFilename=|DataDirectory|\MDD.mdf;Integrated Security=SSPI" providerName="System.Data.SqlClient" /> 
    </connectionStrings> 
    <runtime> 
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> 
     <dependentAssembly> 
     <assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" /> 
     <bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" /> 
     </dependentAssembly> 
    </assemblyBinding> 
    </runtime> 
</configuration> 

После запуска update-database он выдает следующее сообщение об ошибке:

A file activation error occurred. The physical file name '\MDD.mdf' may be incorrect. Diagnose and correct additional errors, and retry the operation. CREATE DATABASE failed. Some file names listed could not be created. Check related errors.

ответ

1

решена.

app.config не должен иметь <connectionStrings>. Web.config делаем. , то в MyDbContext.cs:

public MyDbContext():base("connectionString"){}