mercredi 29 avril 2015

System.Data.Entity.Core.ProviderIncompatibleException - Sqlity trys to create a database

i tried to create a connection to my database. I set my app.config and the other stuff like the standard. I use the entity framework 6 and SQLite in Visual Studio 2013.

app.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <!-- For more information on Entity Framework configuration, visit http://ift.tt/1eigFsq -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>
  <connectionStrings>
    <add name="SPContext" connectionString="Server=(localdb)\v11.0;Integrated Security=true;AttachDBFileName=|DataDirectory|SPDatabase.mdf" providerName="System.Data.SqlClient" />
  </connectionStrings>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
  </startup>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="v11.0" />
      </parameters>
    </defaultConnectionFactory>
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    </providers>
  </entityFramework>
</configuration>

context class

using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DBTest.Model
{
    public class SPContext : DbContext
    {
        //Declare DBSets for each table
        public DbSet<Student> Students { get; set; }

        public SPContext () : base("name=SPContext")
        {

        }   


    }
}

Error:

System.Data.DataException: An exception occurred while initializing the database. See the InnerException for details. ---> System.Data.Entity.Core.ProviderIncompatibleException: CreateDatabase is not supported by the provider..

My question: The Database SPDatabase.sqlite is in the project folder! How can i set, that the provider of sqlite dont try to create a new database?

Thank you.

Aucun commentaire:

Enregistrer un commentaire