I am trying to use the Entity Framework data connection in a Windows Service I have created. The EF model and classes are in a seperate data access assembly. I am referencing the assembly in my service. The coding compiles without any errors. I am using
for example,
using (EntityModel context = new EntityModel)
{
var list = (from a in ctx.TableName Select a);
\\Some insertions to database using EF
}
But the database entry is not working in a windows service even though I reference the data access library.
Yes I have included the connection string in the windows service's app config. Since Windows Service does not contain an app config, I manually added an app config file and entered the connection string located in my EF model. As I have said the data access
logic contains the Entities and logic.
hahs_m
Member
41 Points
59 Posts
Using Entity Framework in Windows Service
May 07, 2012 12:15 PM|LINK
Hi,
I am trying to use the Entity Framework data connection in a Windows Service I have created. The EF model and classes are in a seperate data access assembly. I am referencing the assembly in my service. The coding compiles without any errors. I am using for example,
using (EntityModel context = new EntityModel)
{
var list = (from a in ctx.TableName Select a);
\\Some insertions to database using EF
}
But the database entry is not working in a windows service even though I reference the data access library.
Any suggestions
Thank
hahsm
Ken Tucker
All-Star
16797 Points
2608 Posts
MVP
Re: Using Entity Framework in Windows Service
May 07, 2012 12:22 PM|LINK
Is the entity framework's connection string in the windows service's app config?
Space Coast .Net User Group
hahs_m
Member
41 Points
59 Posts
Re: Using Entity Framework in Windows Service
May 07, 2012 12:24 PM|LINK
Yes I have included the connection string in the windows service's app config. Since Windows Service does not contain an app config, I manually added an app config file and entered the connection string located in my EF model. As I have said the data access logic contains the Entities and logic.
Thanks
hahsm
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: Using Entity Framework in Windows Service
May 09, 2012 02:00 AM|LINK
Hi hahs_m:)
And here's my suggestion for you:
1)You can try to use ASP.NET's work Service。
2)You can also try to use WebService or WCF or something like this to deal with the problem。
Reguards……