c# - ADO.NET creating new Entities object/context exception -
i have problem following code:
public static iqueryable<osoba> getosoby() { using (weryfikacjaentities context = new weryfikacjaentities()) { iqueryable<osoba> user = s in context.osobas select s; return user; } } actually problem occurs in third line, specific at:
weryfikacjaentities context = new weryfikacjaentities() i'm getting exception inner exception says (can't paste it, unless u know polish): "cannot find given connection named in configuration, connection not supposed use entityclient provider or incorrect".
exception itselfs gives me xamlparse
i've use entityframework wizard, guess connection ok. ideas how fix it?
oh getosoby() method called way:
public static list<worker> getworkers() { var u = class1.getosoby().select(x => new worker { _id = x.id, _name = x.imie, _surname = x.nazwisko, _birthdate = x.dataurodzenia, _position = x.stanowisko, _earnings = x.wynagrodzenie, _agegroup = x.grupawiekowa, _department = class1.getdzialy().where( y => y.id == class1.getstanowiska().where( z => z.id == x.stanowisko).firstordefault().id) .firstordefault().id }).tolist(); return (list<worker>)u; } this stacktrace inner exception:
in system.data.entityclient.entityconnection.changeconnectionstring(string newconnectionstring) in system.data.entityclient.entityconnection..ctor(string connectionstring) in system.data.objects.objectcontext.createentityconnection(string connectionstring) in system.data.objects.objectcontext..ctor(string connectionstring, string defaultcontainername) in classlibrary1.weryfikacjaentities..ctor() w c:\users\rufix\documents\visual studio 2010\projects\zadanie 5\classlibrary1\model1.designer.cs:wiersz 40 in classlibrary1.class1.getosoby() w c:\users\rufix\documents\visual studio 2010\projects\zadanie 5\classlibrary1\class1.cs:wiersz 13 in zadanie_5.worker.getworkers() w c:\users\rufix\documents\visual studio 2010\projects\zadanie 5\zadanie 5\worker.cs:wiersz 39 in zadanie_5.mainwindow..ctor() w c:\users\rufix\documents\visual studio 2010\projects\zadanie 5\zadanie 5\mainwindow.xaml.cs:wiersz 26 targetsite: {void changeconnectionstring(system.string)}
when declaring context can specify connection string , can declare db context this:
public class databasecontext : dbcontext { public databasecontext() : base("someconnectionstring"){} { have made sure you're calling right connection string?
if not, please paste rest of inner exception can see it
Comments
Post a Comment