I have created a WPF application that uses Entity Framework/code first on LocalDb (I have created my database on a "model" directory and all seems fine).
It works pretty good on my laptop and I wanted to share it with my friend but it doesn't work. I think I have a SQL error on the other computer but it doesn't show it. It just shows a windows application error... I think it's when I try to load my database context.
My database context:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.Entity;
namespace ModernUINavigationApp1.Model
{
class Supcontext : DbContext
{
public DbSet<InfosConnexion> InfosConnexions { get; set; }
public DbSet<InfosFichiers> InfosFiles { get; set; }
public DbSet<Log> Logs { get; set; }
}
}
My 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>
</configuration>
EDIT:
The localDb is installed, I can build and run a new entity framework solution on every computers and see the localdb on server explorer (on visual studio) for each. On my solution (the one that I try to share) an on an other computer, I have delete the app.config, delete and re-import entity framework, and enable migration and update db on the console and then it works, but it's not the right/better solution I think.
If you open an already existing Visual Studio solution with entity framework (and localdb) from an other computer, you have to delete entity framework from this solution by:
This will generate a new app.config with the correct lines configuration and it should work.
This answer was posted as an edit to the question My WPF/EntityFramework application don't work on other computer by the OP Nimp under CC BY-SA 3.0.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With