Sorry for the delay in responding, dyanaprajna. Time gets away from me sometimes.
Ephesians 2:8 vs Matthew 7:21-23
To let you know where I'm going with this:
You aren't actually quoting two passages that are contradictory. What you are doing is quoting parts of what both Jesus and Paul have taught, but not the wholeness of what they taught, which if taken in isolation might be mistaken as not in harmony if you assume that's all they ever said on the subject of salvation.
However, if we look at the fullness of their teachings we can find that they both expressed the same fullness of ideas about faith and salvation in unison.
To basically sum it up:
Jesus told you that it is necessary to believe and repent, then abide and obey - And Paul teaches the exact same thing.
Neither of them leave out any part of that.
The issue is, what are you to obey? The short answer is, as I will demonstrate, is to obey God directly as He leads you through Holy Spirit, putting your faith in God, which comes to you by believing what Jesus said.
Paul, when he talks of no longer needing to obey the law, speaks of the mosaic statutes, but never speaks of lawlessness in the sense of ignoring God.
Jesus is speaking of God's pure law, which is the command to love God and love others. To that end, the only commandment He gives us is to love God and love others, and then tells us how we can accomplish that.
Paul talks about how if one follows God's law by the Spirit, that there is no need to keep the mosaic statutes anymore because we're already doing what is lawful in God's sight.
The mosaic statutes were only designed to keep us away from sin, but if we are led by the Spirit directly then we won't sin.
 
 
First, let's expand Ephesians a bit to include verse 10:
Ephesians 2
8 For by grace you have been saved through faith. And this is not your own doing; it is the gift of God, 9 not a result of works, so that no one may boast. 10 For we are his workmanship, created in Christ Jesus for good works, which God prepared beforehand, that we should walk in them.
 
From this we see:
-Salvation does not come by works.
-Salvation is a gift, not earned.
-Salvation comes through faith.
-We are still intended to do good works. But the good works prepared by God (that which is the will of the father), and we are called to walk them out.
 
 
Jesus has told us the same thing:
That salvation is a gift
That salvation comes by faith
And in Mathew 7 itself, we see Jesus saying that works alone are not going to gain you entrance.
 
Salvation comes as a gift, by faith:
John 3
16 For God so loved the world that he gave his one and only Son, that whoever believes in him shall not perish but have eternal life.
John 5
24 "Very truly I tell you, whoever hears my word and believes him who sent me has eternal life and will not be judged but has crossed over from death to life.
John 10
28 I give them eternal life, and they will never perish, and no one will snatch them out of my hand.
 
 
 
Paul also teaches that it is necessary to do the will of the Father, in the sense that actions of obediance and love follow one who has true faith:
"Works of faith" are that which flow out of your faith. They are not that which grants you salvation. But one who has true faith will manifest the works of faith just as one who abides in the Spirit will manifest the fruit of the Spirit.
This is also consistent with what Paul says in Ephesians 2 when he talks about how God has prepared good works for us that we should walk in them.
 
Hebrews 10
36 For you have need of endurance, so that when you have done the will of God you may receive what is promised. 37 For,
"Yet a little while,
and the coming one will come and will not delay;
38 but my righteous one shall live by faith,
and if he shrinks back,
my soul has no pleasure in him."
39 But we are not of those who shrink back and are destroyed, but of those who have faith and preserve their souls.
 
Hebrews 11
7 By faith Noah, being warned by God concerning events as yet unseen, in reverent fear constructed an ark for the saving of his household. By this he condemned the world and became an heir of the righteousness that comes by faith.
By faith Abraham obeyed when he was called to go out to a place that he was to receive as an inheritance. And he went out, not knowing where he was going.
 
30 By faith the walls of Jericho fell down after they had been encircled for seven days.
 
Romans 1:5
5 through whom we have received grace and apostleship to bring about the obedience of faith for the sake of his name among all the nations,
 
Romans 16:26
26 but has now been disclosed and through the prophetic writings has been made known to all nations, according to the command of the eternal God, to bring about the obedience of faith—
 
2 Thess. 1
11 So we keep on praying for you, asking our God to enable you to live a life worthy of his call. May he give you the power to accomplish all the good things your faith prompts you to do.
 
1 Thess. 1:3
3 remembering before our God and Father your work of faith and labor of love and steadfastness of hope in our Lord Jesus Christ.
 
Galatians 5
6 For in Christ Jesus neither circumcision nor uncircumcision counts for anything, but only faith working through love.
 
 
Here in Romans, Paul links life with not merely faith, but faith that abides in the Spirit and sets themselves to the things of the Spirit, which results in submission to God's law and righteousness. To set your mind on the things of the Spirit is to do the will of the Spirit, thus doing the will of the Father, and this leads to life.
(This parallels Jesus's teaching in Matthew 7 and John 15 about the necessity of abiding in Him, His Spirit dwelling in us, as a necessity to produce righteous fruit)
 
Romans 6:
20 For when you were slaves of sin, you were free in regard to righteousness. 21 But what fruit were you getting at that time from the things of which you are now ashamed? For the end of those things is death. 22 But now that you have been set free from sin and have become slaves of God, the fruit you get leads to sanctification and its end, eternal life. 23 For the wages of sin is death, but the free gift of God is eternal life in Christ Jesus our Lord.
Romans 8
5 For those who live according to the flesh set their minds on the things of the flesh, but those who live according to the Spirit set their minds on the things of the Spirit. 6 For to set the mind on the flesh is death, but to set the mind on the Spirit is life and peace. 7 For the mind that is set on the flesh is hostile to God, for it does not submit to God's law; indeed, it cannot. 8 Those who are in the flesh cannot please God.
9 You, however, are not in the flesh but in the Spirit, if in fact the Spirit of God dwells in you. Anyone who does not have the Spirit of Christ does not belong to him. 10 But if Christ is in you, although the body is dead because of sin, the Spirit is life because of righteousness. 11 If the Spirit of him who raised Jesus from the dead dwells in you, he who raised Christ Jesus from the dead will also give life to your mortal bodies through his Spirit who dwells in you.
12 So then, brothers, we are debtors, not to the flesh, to live according to the flesh. 13 For if you live according to the flesh you will die, but if by the Spirit you put to death the deeds of the body, you will live. 14 For all who are led by the Spirit of God are sons of God.
 
 
The other writers are in harmony with this:
1 john 2
28 And now, little children, abide in him, so that when he appears we may have confidence and not shrink from him in shame at his coming. 29 If you know that he is righteous, you may be sure that everyone who practices righteousness has been born of him.
1 Peter 1:14
14 As obedient children, do not be conformed to the passions of your former ignorance,
Acts 5
32 And we are witnesses to these things, and so is the Holy Spirit, whom God has given to those who obey him."