Posts Tagged bikash

Unable to update the EntitySet ‘yourTableName’ because it has a DefiningQuery and no element exists in the element to support the current operation.

Recently i am switching to MVC4 with Razor view engine for ASP.NET, C# web application.  Tomorrow i was developing a blogging site where there were some works related to database. There i have created a table with 4 columns but none of them were made primary key.

When i tried to run the application the visual studio 2012 shows the error “Unable to update the EntitySet ‘UserTable’ because it has a DefiningQuery and no <InsertFunction> element exists in the <ModificationFunctionMapping> element to support the current operation.” Here UserTable was my table name.

The database was sql server compact edition of visual studio 2012. I became confused about the error because this type of table with no primary key works well before. After a while i came to know that the problem was because of the lacking of primary key in the table. when i mark one of the columns as a primary key then the project run without error. This type of error was new to me so i thought to write down here so later on it may be helpful to someone like me.

Summary of the error and solution:

Problem: No primary key in the table

Solution: Add a primary key in the table



Happy Coding……….

Bikash, Software Engineer.


, , , , , , , ,

Leave a comment

Prolog code for maximum, minimum, oddeven, permutation and nth element

Maximum number:

C2 is max(C,H),

Input and output:


Minimum number:

minl([Only], Only).
minl([Head|Tail], Minimum) :-
minl(Tail, TailMin),
Minimum is min(Head, TailMin).

Input  =  minl([4,5,1,2,9],X).

Odd or even:

odd_even(X):- X mod 2 =:= 0,
write(‘even number’),nl.

odd_even(X):- write(‘odd number’),nl.





Nth element:

nth(Count, Item, [_|Tail]):-
Count > 1,
Count0 is Count-1,
nth(Count0, Item, Tail).


%ache kina chke kre yes or no rslt



, , , , , , , ,

Leave a comment

Prolog code for fibonacci series and number

Finding fibonacci series:
:- dynamic(stored/1).
memo(Goal) :-
stored(Goal) -> true;
Goal, assertz(stored(Goal)).

fib(1,1) :- !, write(‘1, ‘).
fib(2,1) :- !, write(‘1, ‘).
fib(N,F) :-
N1 is N-1, memo(fib(N1,F1)),
N2 is N-2, memo(fib(N2,F2)),
F is F1 + F2,
write(F), write(‘, ‘).

Input   = fib(7,X).

Output: 1, 1, 2, 3, 5, 8, 13

Other fibonacci code:

fib(X, Ans) :- Xm1 is X – 1 ,Xm2 is X – 2 ,
fib(Xm1, Sub1), fib(Xm2, Sub2),
Ans is Sub1 + Sub2.

fib(0,A). means  A=0; 0 tomo fibonacci number is 0
fib(7,A).  A=13;  7  th fibonacci number is 13
fibonacci series: 0,1,1,2,3,5,8,13,21,34,55,89,144;

another one:

N3 is N1+N2,

%fib_for(FirstNumber, SecondNumber, Result).
%   Example:  ?-fib_for(1,1,Result).

%at first have to provide two fibonacci number then have to start execution, when executing have to press ; for next fibonacci number.

, , ,

1 Comment

Prolog code for prime number, power calculation and factorial

Checking prime number:

N is Y*Y,
N =< X,
X mod Y =:= 0.

Y < X,
Y1 is Y+1,

Y is 2, X > 1, \+divisible(X,Y).

Input:  isprime(7).

Output: Yes

Finding power of a number:

power(0,N,0):- N>0.
power(X,0,1):- X>0.
power(X,N,V):-X>0,N>0,N1 is N-1,power(X,N1,V1), V is V1*X.

Input: power(2,4,P).

Output:  V=16

Finding factorial of a number:

X1 is X-1,
Y is X*Z.

Input:  fact(3,X).

Output: X=6

, , , ,

Leave a comment